Accept "Z" as the zulu timezone at the end of date strings. (CVS 4805)

FossilOrigin-Name: 4c9a7b42b797f42f2b1e2e8d6a260044bd22ef2d
This commit is contained in:
drh 2008-02-21 20:40:43 +00:00
parent b4d58ae74d
commit 1cfdc90b43
4 changed files with 35 additions and 17 deletions

View File

@ -1,5 +1,5 @@
C Updates\sto\sAPI\sdocumentation\scontained\sin\scomments\sof\ssqlite.h.in.\s(CVS\s4804) C Accept\s"Z"\sas\sthe\szulu\stimezone\sat\sthe\send\sof\sdate\sstrings.\s(CVS\s4805)
D 2008-02-21T20:17:07 D 2008-02-21T20:40:44
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in bc2b5df3e3d0d4b801b824b7ef6dec43812b049b F Makefile.in bc2b5df3e3d0d4b801b824b7ef6dec43812b049b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -90,7 +90,7 @@ F src/btreeInt.h 97a68823481e769874f9a61ef43719c856c71860
F src/build.c 7d93ee565b5676746d014acdc638adee87cfd27e F src/build.c 7d93ee565b5676746d014acdc638adee87cfd27e
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0 F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131 F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
F src/date.c 8ce763c68143b1e8fb6f79dcfc8b801853c97017 F src/date.c 187cad26eaaecd7bcdccd49d5a70c5aa3010bc74
F src/delete.c fa13c296262e89c32d28949f15be275e52d7f524 F src/delete.c fa13c296262e89c32d28949f15be275e52d7f524
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c e6fb42c6e55fd9526174b1cb8296b69a60a6688a F src/expr.c e6fb42c6e55fd9526174b1cb8296b69a60a6688a
@ -253,7 +253,7 @@ F test/crash4.test 02ff4f15c149ca1e88a5c299b4896c84d9450c3b
F test/crash5.test c7ddcf7ca83abc19901b977732144234ac72a938 F test/crash5.test c7ddcf7ca83abc19901b977732144234ac72a938
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test 199cf68f44e5d9e87a0b8afc7130fdeb4def3272 F test/createtab.test 199cf68f44e5d9e87a0b8afc7130fdeb4def3272
F test/date.test 51734f3798f338e3f75107aff5a057ae0ff7006c F test/date.test 8db95a0ba2c8f4c8762ce66859a036c51959a6be
F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb
F test/delete.test 57533e88e886608bf5ae0f394e14c2eb1b1f7754 F test/delete.test 57533e88e886608bf5ae0f394e14c2eb1b1f7754
F test/delete2.test c06be3806ba804bc8c6f134476816080280b40e3 F test/delete2.test c06be3806ba804bc8c6f134476816080280b40e3
@ -621,7 +621,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P e0baceac412b85348e67f2376ea10000e1f76ab8 P 08276df3fdd63f210d502c414390f1efd8ebbbb7
R e570a50bbec8e6f96cc3d8ea4bc61a43 R fbd8410911af3170ba7036428f73329b
U drh U drh
Z d863c10026954c8f485f02ede9d18d3b Z 2bd7a33d27840649099691bbdad59fdc

View File

@ -1 +1 @@
08276df3fdd63f210d502c414390f1efd8ebbbb7 4c9a7b42b797f42f2b1e2e8d6a260044bd22ef2d

View File

@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope. ** All other code has file scope.
** **
** $Id: date.c,v 1.75 2008/01/17 22:27:54 drh Exp $ ** $Id: date.c,v 1.76 2008/02/21 20:40:44 drh Exp $
** **
** SQLite processes all times and dates as Julian Day numbers. The ** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon ** dates and times are stored as the number of days since noon
@ -131,23 +131,32 @@ end_getDigits:
** **
** (+/-)HH:MM ** (+/-)HH:MM
** **
** Or the "zulu" notation:
**
** Z
**
** If the parse is successful, write the number of minutes ** If the parse is successful, write the number of minutes
** of change in *pnMin and return 0. If a parser error occurs, ** of change in p->tz and return 0. If a parser error occurs,
** return 0. ** return non-zero.
** **
** A missing specifier is not considered an error. ** A missing specifier is not considered an error.
*/ */
static int parseTimezone(const char *zDate, DateTime *p){ static int parseTimezone(const char *zDate, DateTime *p){
int sgn = 0; int sgn = 0;
int nHr, nMn; int nHr, nMn;
int c;
while( isspace(*(u8*)zDate) ){ zDate++; } while( isspace(*(u8*)zDate) ){ zDate++; }
p->tz = 0; p->tz = 0;
if( *zDate=='-' ){ c = *zDate;
if( c=='-' ){
sgn = -1; sgn = -1;
}else if( *zDate=='+' ){ }else if( c=='+' ){
sgn = +1; sgn = +1;
}else if( c=='Z' || c=='z' ){
zDate++;
goto zulu_time;
}else{ }else{
return *zDate!=0; return c!=0;
} }
zDate++; zDate++;
if( getDigits(zDate, 2, 0, 14, ':', &nHr, 2, 0, 59, 0, &nMn)!=2 ){ if( getDigits(zDate, 2, 0, 14, ':', &nHr, 2, 0, 59, 0, &nMn)!=2 ){
@ -155,6 +164,7 @@ static int parseTimezone(const char *zDate, DateTime *p){
} }
zDate += 5; zDate += 5;
p->tz = sgn*(nMn + nHr*60); p->tz = sgn*(nMn + nHr*60);
zulu_time:
while( isspace(*(u8*)zDate) ){ zDate++; } while( isspace(*(u8*)zDate) ){ zDate++; }
return *zDate!=0; return *zDate!=0;
} }

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this file is testing date and time functions. # focus of this file is testing date and time functions.
# #
# $Id: date.test,v 1.24 2008/01/17 22:27:54 drh Exp $ # $Id: date.test,v 1.25 2008/02/21 20:40:44 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -191,8 +191,16 @@ datetest 5.2 {datetime('1994-04-16 14:00:00 -05:15')} {1994-04-16 19:15:00}
datetest 5.3 {datetime('1994-04-16 05:00:00 +08:30')} {1994-04-15 20:30:00} datetest 5.3 {datetime('1994-04-16 05:00:00 +08:30')} {1994-04-15 20:30:00}
datetest 5.4 {datetime('1994-04-16 14:00:00 -11:55')} {1994-04-17 01:55:00} datetest 5.4 {datetime('1994-04-16 14:00:00 -11:55')} {1994-04-17 01:55:00}
datetest 5.5 {datetime('1994-04-16 14:00:00 -11:60')} NULL datetest 5.5 {datetime('1994-04-16 14:00:00 -11:60')} NULL
datetest 5.4 {datetime('1994-04-16 14:00:00 -11:55 ')} {1994-04-17 01:55:00} datetest 5.6 {datetime('1994-04-16 14:00:00 -11:55 ')} {1994-04-17 01:55:00}
datetest 5.4 {datetime('1994-04-16 14:00:00 -11:55 x')} NULL datetest 5.7 {datetime('1994-04-16 14:00:00 -11:55 x')} NULL
datetest 5.8 {datetime('1994-04-16T14:00:00Z')} {1994-04-16 14:00:00}
datetest 5.9 {datetime('1994-04-16 14:00:00z')} {1994-04-16 14:00:00}
datetest 5.10 {datetime('1994-04-16 14:00:00 Z')} {1994-04-16 14:00:00}
datetest 5.11 {datetime('1994-04-16 14:00:00z ')} {1994-04-16 14:00:00}
datetest 5.12 {datetime('1994-04-16 14:00:00 z ')} {1994-04-16 14:00:00}
datetest 5.13 {datetime('1994-04-16 14:00:00Zulu')} NULL
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 # localtime->utc and utc->localtime conversions. These tests only work
# if the localtime is in the US Eastern Time (the time in Charlotte, NC # if the localtime is in the US Eastern Time (the time in Charlotte, NC