Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When converting a DateTime instance of an 'Unspecified' kind to a string, use the same kind as the connection, if available. Also, cleanup handling of the default formats for UTC and local time. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | logBind |
Files: | files | file ages | folders |
SHA1: |
dbdf2561a44fabd61459f0d656decf62 |
User & Date: | mistachkin 2012-02-19 13:22:08.521 |
Context
2012-02-19
| ||
13:31 | Merge fix for ticket [8a426d12eb] along with logging and DateTime handling enhancements to trunk. check-in: c3bb6c2582 user: mistachkin tags: trunk | |
13:22 | When converting a DateTime instance of an 'Unspecified' kind to a string, use the same kind as the connection, if available. Also, cleanup handling of the default formats for UTC and local time. Closed-Leaf check-in: dbdf2561a4 user: mistachkin tags: logBind | |
08:34 | Refactor previous commit to remove the new delegates as they are not strictly required. Also, remove superfluous newData local variable in the StepCallback method. check-in: c43fca0ae6 user: mistachkin tags: logBind | |
Changes
Changes to System.Data.SQLite/SQLiteConvert.cs.
︙ | ︙ | |||
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | "yyyyMMddHHmm", "yyyyMMddTHHmmssFFFFFFF", "yyyy-MM-dd", "yyyyMMdd", "yy-MM-dd" }; /// <summary> /// An UTF-8 Encoding instance, so we can convert strings to and from UTF-8 /// </summary> private static Encoding _utf8 = new UTF8Encoding(); /// <summary> /// The default DateTime format for this instance /// </summary> | > > > > > > > > > > > > | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | "yyyyMMddHHmm", "yyyyMMddTHHmmssFFFFFFF", "yyyy-MM-dd", "yyyyMMdd", "yy-MM-dd" }; /// <summary> /// The internal default format for UTC DateTime values when converting /// to a string. /// </summary> private static readonly string _datetimeFormatUtc = _datetimeFormats[5]; /// <summary> /// The internal default format for local DateTime values when converting /// to a string. /// </summary> private static readonly string _datetimeFormatLocal = _datetimeFormats[19]; /// <summary> /// An UTF-8 Encoding instance, so we can convert strings to and from UTF-8 /// </summary> private static Encoding _utf8 = new UTF8Encoding(); /// <summary> /// The default DateTime format for this instance /// </summary> |
︙ | ︙ | |||
345 346 347 348 349 350 351 352 353 354 355 356 357 358 | /// </summary> /// <param name="value">The DateTime to convert</param> /// <returns>The JulianDay value the Datetime represents</returns> public static double ToJulianDay(DateTime value) { return value.ToOADate() + OleAutomationEpochAsJulianDay; } /// <summary> /// Converts a DateTime to a string value, using the current DateTimeFormat specified for the connection when it was opened. /// </summary> /// <param name="dateValue">The DateTime value to convert</param> /// <returns>Either a string containing the long integer number of 100-nanosecond units since System.DateTime.MinValue, a /// Julian day double, an integer number of seconds since the Unix epoch, a culture-independent formatted date and time | > > > > > > > > > > > > > | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | /// </summary> /// <param name="value">The DateTime to convert</param> /// <returns>The JulianDay value the Datetime represents</returns> public static double ToJulianDay(DateTime value) { return value.ToOADate() + OleAutomationEpochAsJulianDay; } /// <summary> /// Returns the default DateTime format string to use for the specified /// DateTimeKind. /// </summary> /// <param name="kind">The DateTimeKind to use.</param> /// <returns> /// The default DateTime format string to use for the specified DateTimeKind. /// </returns> private static string GetDateTimeKindFormat(DateTimeKind kind) { return (kind == DateTimeKind.Utc) ? _datetimeFormatUtc : _datetimeFormatLocal; } /// <summary> /// Converts a DateTime to a string value, using the current DateTimeFormat specified for the connection when it was opened. /// </summary> /// <param name="dateValue">The DateTime value to convert</param> /// <returns>Either a string containing the long integer number of 100-nanosecond units since System.DateTime.MinValue, a /// Julian day double, an integer number of seconds since the Unix epoch, a culture-independent formatted date and time |
︙ | ︙ | |||
368 369 370 371 372 373 374 | case SQLiteDateFormats.UnixEpoch: return ((long)(dateValue.Subtract(UnixEpoch).Ticks / TimeSpan.TicksPerSecond)).ToString(); case SQLiteDateFormats.InvariantCulture: return dateValue.ToString(FullFormat, CultureInfo.InvariantCulture); case SQLiteDateFormats.CurrentCulture: return dateValue.ToString(FullFormat, CultureInfo.CurrentCulture); default: | | > | | | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | case SQLiteDateFormats.UnixEpoch: return ((long)(dateValue.Subtract(UnixEpoch).Ticks / TimeSpan.TicksPerSecond)).ToString(); case SQLiteDateFormats.InvariantCulture: return dateValue.ToString(FullFormat, CultureInfo.InvariantCulture); case SQLiteDateFormats.CurrentCulture: return dateValue.ToString(FullFormat, CultureInfo.CurrentCulture); default: return (dateValue.Kind == DateTimeKind.Unspecified) ? DateTime.SpecifyKind(dateValue, _datetimeKind).ToString( GetDateTimeKindFormat(_datetimeKind), CultureInfo.InvariantCulture) : dateValue.ToString(GetDateTimeKindFormat(dateValue.Kind), CultureInfo.InvariantCulture); } } /// <summary> /// Internal function to convert a UTF-8 encoded IntPtr of the specified length to a DateTime. /// </summary> /// <remarks> |
︙ | ︙ |