Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add experimental port of the Julian Day handling functions from the SQLite core library. Still needs tests. Pursuant to [3e783eecbe]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | newJulianDay |
Files: | files | file ages | folders |
SHA1: |
fe17cded54f1faf8fcc52ece5aae977c |
User & Date: | mistachkin 2014-10-31 21:36:38.147 |
Context
2014-10-31
| ||
22:40 | Improve handling of out-of-range Julian Day values. check-in: c559792dba user: mistachkin tags: newJulianDay | |
21:36 | Add experimental port of the Julian Day handling functions from the SQLite core library. Still needs tests. Pursuant to [3e783eecbe]. check-in: fe17cded54 user: mistachkin tags: newJulianDay | |
2014-10-30
| ||
01:12 | Update SQLite core library to the 3.8.7.1 release. check-in: 5074b140f0 user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteConvert.cs.
︙ | ︙ | |||
202 203 204 205 206 207 208 209 210 211 212 213 214 215 | return _utf8.GetString(byteArray, 0, nativestringlen); } #endregion #region DateTime Conversion Functions /// <summary> /// Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, /// and DateTimeFormatString specified for the connection when it was opened. /// </summary> /// <remarks> /// Acceptable ISO8601 DateTime formats are: /// <list type="bullet"> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | return _utf8.GetString(byteArray, 0, nativestringlen); } #endregion #region DateTime Conversion Functions #region New Julian Day Conversion Methods /// <summary> /// Converts a Julian Day number to a <see cref="DateTime" />. /// This function was copied from the "date.c" file belonging /// to the SQLite core library. /// </summary> /// <param name="jd"> /// The Julian Day number to convert. /// </param> /// <returns> /// A <see cref="DateTime" /> value that contains the year, month, and day /// values that are closest to the specified Julian Day value. /// </returns> private static DateTime computeYMD( long jd ) { int Z, A, B, C, D, E, X1; Z = (int)((jd + 43200000) / 86400000); A = (int)((Z - 1867216.25) / 36524.25); A = Z + 1 + A - (A / 4); B = A + 1524; C = (int)((B - 122.1) / 365.25); D = (36525 * C) / 100; E = (int)((B - D) / 30.6001); X1 = (int)(30.6001 * E); int day, month, year; day = B - D - X1; month = E < 14 ? E - 1 : E - 13; year = month > 2 ? C - 4716 : C - 4715; return new DateTime(year, month, day); } /////////////////////////////////////////////////////////////////////////// /// <summary> /// Converts a Julian Day number to a <see cref="DateTime" />. /// This function was copied from the "date.c" file belonging /// to the SQLite core library. /// </summary> /// <param name="jd"> /// The Julian Day number to convert. /// </param> /// <returns> /// A <see cref="DateTime" /> value that contains the hour, minute, and /// second values that are closest to the specified Julian Day value. /// </returns> private static DateTime computeHMS( long jd ) { int s; s = (int)((jd + 43200000) % 86400000); double seconds; seconds = s / 1000.0; s = (int)seconds; seconds -= s; int hour; hour = s / 3600; s -= hour * 3600; int minute; minute = s / 60; seconds += s - minute * 60; int second = (int)Math.Truncate(seconds); int millisecond = (int)((seconds - second) * 1000.0); DateTime minValue = DateTime.MinValue; return new DateTime( minValue.Year, minValue.Month, minValue.Day, hour, minute, second, millisecond); } /////////////////////////////////////////////////////////////////////////// /// <summary> /// Converts a <see cref="DateTime" /> to a Julian Day number. /// This function was copied from the "date.c" file belonging /// to the SQLite core library. /// </summary> /// <param name="dateTime"> /// The <see cref="DateTime" /> value to convert. /// </param> /// <returns> /// The nearest Julian Day number corresponding to the specified /// <see cref="DateTime" /> value. /// </returns> private static long computeJD( DateTime dateTime ) { int Y, M, D; Y = dateTime.Year; M = dateTime.Month; D = dateTime.Day; if (M <= 2) { Y--; M += 12; } int A, B, X1, X2; A = Y / 100; B = 2 - A + (A / 4); X1 = 36525 * (Y + 4716) / 100; X2 = 306001 * (M + 1) / 10000; long jd; jd = (long)((X1 + X2 + D + B - 1524.5) * 86400000); jd += dateTime.Hour * 3600000 + dateTime.Minute * 60000 + (long)(dateTime.Second * 1000); return jd; } #endregion /////////////////////////////////////////////////////////////////////////// /// <summary> /// Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, /// and DateTimeFormatString specified for the connection when it was opened. /// </summary> /// <remarks> /// Acceptable ISO8601 DateTime formats are: /// <list type="bullet"> |
︙ | ︙ |