SQLite

Check-in [14226ff0a7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added more DST boundary checks for 2006 and 2007. Added check for suspect Windows DST implementations and warning about them. Ticket #2322. (CVS 5147)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 14226ff0a7af7b39a1089a17eeb5bbb8d09d778d
User & Date: shane 2008-05-20 14:01:59.000
Context
2008-05-20
15:44
Changes to the error handling policies of sqlite3_exec() to make them more consistent. Changes to the documentation on the error handling polices of sqlite3_exec() so that the documentation and code agree. (CVS 5148) (check-in: a0376c7907 user: drh tags: trunk)
14:01
Added more DST boundary checks for 2006 and 2007. Added check for suspect Windows DST implementations and warning about them. Ticket #2322. (CVS 5147) (check-in: 14226ff0a7 user: shane tags: trunk)
13:17
Updated test case for Windows to get around problems in ticket #3129. (CVS 5146) (check-in: 2faf69ca1d user: shane tags: trunk)
Changes
Unified Diff Show Whitespace Changes Patch
Changes to test/date.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2003 October 31
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing date and time functions.
#
# $Id: date.test,v 1.26 2008/04/15 04:02:41 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Skip this whole file if date and time functions are omitted
# at compile-time
#













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2003 October 31
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing date and time functions.
#
# $Id: date.test,v 1.27 2008/05/20 14:01:59 shane Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Skip this whole file if date and time functions are omitted
# at compile-time
#
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
datetest 5.14 {datetime('1994-04-16 14:00:00Z +05:00')} NULL
datetest 5.15 {datetime('1994-04-16 14:00:00 +05:00 Z')} NULL

# localtime->utc and utc->localtime conversions.  These tests only work
# if the localtime is in the US Eastern Time (the time in Charlotte, NC
# and in New York.)
#













set tzoffset [db one {
  SELECT CAST(24*(julianday('2006-09-01') -
                  julianday('2006-09-01','localtime'))+0.5
              AS INT)
}]


















if {$tzoffset==4} {
  datetest 6.1 {datetime('2000-10-29 05:59:00','localtime')}\
      {2000-10-29 01:59:00}







  datetest 6.2 {datetime('2000-10-29 06:00:00','localtime')}\
      {2000-10-29 01:00:00}








  datetest 6.3 {datetime('2000-04-02 06:59:00','localtime')}\
      {2000-04-02 01:59:00}






  datetest 6.4 {datetime('2000-04-02 07:00:00','localtime')}\
      {2000-04-02 03:00:00}





  datetest 6.5 {datetime('2000-10-29 01:59:00','utc')} {2000-10-29 05:59:00}





  datetest 6.6 {datetime('2000-10-29 02:00:00','utc')} {2000-10-29 07:00:00}






  datetest 6.7 {datetime('2000-04-02 01:59:00','utc')} {2000-04-02 06:59:00}




  datetest 6.8 {datetime('2000-04-02 02:00:00','utc')} {2000-04-02 06:00:00}



  datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \
      {2000-01-01 07:00:00}
  datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \
      {1969-01-01 07:00:00}
  datetest 6.12 {datetime('2039-01-01 12:00:00','localtime')} \
      {2039-01-01 07:00:00}







>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|


>
>
>
>
>
>
>


>
>
>
>
>
>
>
>


>
>
>
>
>
>


>
>
>
>
>

>
>
>
>
>

>
>
>
>
>
>

>
>
>
>

>
>







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
datetest 5.14 {datetime('1994-04-16 14:00:00Z +05:00')} NULL
datetest 5.15 {datetime('1994-04-16 14:00:00 +05:00 Z')} NULL

# localtime->utc and utc->localtime conversions.  These tests only work
# if the localtime is in the US Eastern Time (the time in Charlotte, NC
# and in New York.)
#
# On non-Vista Windows platform, '2006-03-31' is treated incorrectly as being
# in DST giving a 4 hour offset instead of 5.  In 2007, DST was extended to 
# start three weeks earlier (second Sunday in March) and end one week
# later (first Sunday in November).  Older Windows systems apply this
# new rule incorrectly to dates prior to 2007.
#
# It might be argued that this is masking a problem on non-Vista Windows
# platform.  A ticket has already been opened for this issue 
# (http://www.sqlite.org/cvstrac/tktview?tn=2322).  This is just to prevent
# more confusion/reports of the issue.
#

# $tzoffset_old should be 5 if DST is working correctly.
set tzoffset_old [db one {
  SELECT CAST(24*(julianday('2006-03-31') -
                  julianday('2006-03-31','localtime'))+0.5
              AS INT)
}]

# $tzoffset_new should be 4 if DST is working correctly.
set tzoffset_new [db one {
  SELECT CAST(24*(julianday('2007-03-31') -
                  julianday('2007-03-31','localtime'))+0.5
              AS INT)
}]

# Warn about possibly broken Windows DST implementations.
if {$::tcl_platform(platform)=="windows" && $tzoffset_new==4 && $tzoffset_old==4} {
  puts "******************************************************************"
  puts "N.B.:  The DST support provided by your current O/S seems to be"
  puts "suspect in that it is reporting incorrect DST values for dates"
  puts "prior to 2007.  This is the known case for most (all?) non-Vista"
  puts "Windows versions.  Please see ticket #2322 for more information."
  puts "******************************************************************"
}

if {$tzoffset_new==4} {
  datetest 6.1 {datetime('2000-10-29 05:59:00','localtime')}\
      {2000-10-29 01:59:00}
  datetest 6.1.1 {datetime('2006-10-29 05:59:00','localtime')}\
      {2006-10-29 01:59:00}
  datetest 6.1.2 {datetime('2007-11-04 05:59:00','localtime')}\
      {2007-11-04 01:59:00}

  # If the new and old DST rules seem to be working correctly...
  if {$tzoffset_new==4 && $tzoffset_old==5} {
  datetest 6.2 {datetime('2000-10-29 06:00:00','localtime')}\
      {2000-10-29 01:00:00}
    datetest 6.2.1 {datetime('2006-10-29 06:00:00','localtime')}\
        {2006-10-29 01:00:00}
  }
  datetest 6.2.2 {datetime('2007-11-04 06:00:00','localtime')}\
      {2007-11-04 01:00:00}

  # If the new and old DST rules seem to be working correctly...
  if {$tzoffset_new==4 && $tzoffset_old==5} {
  datetest 6.3 {datetime('2000-04-02 06:59:00','localtime')}\
      {2000-04-02 01:59:00}
    datetest 6.3.1 {datetime('2006-04-02 06:59:00','localtime')}\
        {2006-04-02 01:59:00}
  }
  datetest 6.3.2 {datetime('2007-03-11 07:00:00','localtime')}\
      {2007-03-11 03:00:00}

  datetest 6.4 {datetime('2000-04-02 07:00:00','localtime')}\
      {2000-04-02 03:00:00}
  datetest 6.4.1 {datetime('2006-04-02 07:00:00','localtime')}\
      {2006-04-02 03:00:00}
  datetest 6.4.2 {datetime('2007-03-11 07:00:00','localtime')}\
      {2007-03-11 03:00:00}
      
  datetest 6.5 {datetime('2000-10-29 01:59:00','utc')} {2000-10-29 05:59:00}
  datetest 6.5.1 {datetime('2006-10-29 01:59:00','utc')} {2006-10-29 05:59:00}
  datetest 6.5.2 {datetime('2007-11-04 01:59:00','utc')} {2007-11-04 05:59:00}

  # If the new and old DST rules seem to be working correctly...
  if {$tzoffset_new==4 && $tzoffset_old==5} {
  datetest 6.6 {datetime('2000-10-29 02:00:00','utc')} {2000-10-29 07:00:00}
    datetest 6.6.1 {datetime('2006-10-29 02:00:00','utc')} {2006-10-29 07:00:00}
  }
  datetest 6.6.2 {datetime('2007-11-04 02:00:00','utc')} {2007-11-04 07:00:00}

  # If the new and old DST rules seem to be working correctly...
  if {$tzoffset_new==4 && $tzoffset_old==5} {
  datetest 6.7 {datetime('2000-04-02 01:59:00','utc')} {2000-04-02 06:59:00}
    datetest 6.7.1 {datetime('2006-04-02 01:59:00','utc')} {2006-04-02 06:59:00}
  }
  datetest 6.7.2 {datetime('2007-03-11 01:59:00','utc')} {2007-03-11 06:59:00}

  datetest 6.8 {datetime('2000-04-02 02:00:00','utc')} {2000-04-02 06:00:00}
  datetest 6.8.1 {datetime('2006-04-02 02:00:00','utc')} {2006-04-02 06:00:00}
  datetest 6.8.2 {datetime('2007-03-11 02:00:00','utc')} {2007-03-11 06:00:00}

  datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \
      {2000-01-01 07:00:00}
  datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \
      {1969-01-01 07:00:00}
  datetest 6.12 {datetime('2039-01-01 12:00:00','localtime')} \
      {2039-01-01 07:00:00}
372
373
374
375
376
377
378
379
380
381
  {2007-01-01 12:59:59}
datetest 13.5 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 12:59:59.6')} \
  {2007-01-01 12:59:59.600}
datetest 13.6 {strftime('%Y-%m-%d %H:%M:%S', '2007-01-01 23:59:59.6')} \
  {2007-01-01 23:59:59}
datetest 13.7 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 23:59:59.6')} \
  {2007-01-01 23:59:59.600}


finish_test








<

446
447
448
449
450
451
452
453

454
  {2007-01-01 12:59:59}
datetest 13.5 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 12:59:59.6')} \
  {2007-01-01 12:59:59.600}
datetest 13.6 {strftime('%Y-%m-%d %H:%M:%S', '2007-01-01 23:59:59.6')} \
  {2007-01-01 23:59:59}
datetest 13.7 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 23:59:59.6')} \
  {2007-01-01 23:59:59.600}


finish_test