Fossil SCM

Round ISO date/time values that are not specified out to the last second up to the largest value that is still consistent with the supplied prefix, as these values are used for search with <=.

drh 2025-03-17 21:37 trunk
Commit 515a4d81917e9f05bb2e61273b4aef282c47bc63b3d58ffc5249acfa1f5f1b25
1 file changed +16 -7
+16 -7
--- src/name.c
+++ src/name.c
@@ -58,13 +58,19 @@
5858
** Check to see if the string might be a compact date/time that omits
5959
** the punctuation. Example: "20190327084549" instead of
6060
** "2019-03-27 08:45:49". If the string is of the appropriate form,
6161
** then return an alternative string (in static space) that is the same
6262
** string with punctuation inserted.
63
+**
64
+** Assume the maximum allowed value for unspecified digits. In other
65
+** words: 202503171234 -> 2025-03-17 12:34:59
66
+** ^^--- Added seconds.
67
+** and: 20250317 -> 2025-03-17 23:59:59
68
+** ^^^^^^^^--- Added time.
6369
**
6470
** If the bVerifyNotAHash flag is true, then a check is made to see if
65
-** the string is a hash prefix and NULL is returned if it is. If the
71
+** the input string is a hash prefix and NULL is returned if it is. If the
6672
** bVerifyNotAHash flag is false, then the result is determined by syntax
6773
** of the input string only, without reference to the artifact table.
6874
*/
6975
char *fossil_expand_datetime(const char *zIn, int bVerifyNotAHash){
7076
static char zEDate[24];
@@ -74,12 +80,12 @@
7480
int addZulu = 0;
7581
7682
/* These forms are allowed:
7783
**
7884
** 123456789 1234 123456789 123456789
79
- ** (1) YYYYMMDD => YYYY-MM-DD
80
- ** (2) YYYYMMDDHHMM => YYYY-MM-DD HH:MM
85
+ ** (1) YYYYMMDD => YYYY-MM-DD 23:59:59
86
+ ** (2) YYYYMMDDHHMM => YYYY-MM-DD HH:MM:59
8187
** (3) YYYYMMDDHHMMSS => YYYY-MM-DD HH:MM:SS
8288
**
8389
** An optional "Z" zulu timezone designator is allowed at the end.
8490
*/
8591
if( n>0 && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){
@@ -98,16 +104,19 @@
98104
for(i=j=0; i<n; i++){
99105
if( i>=4 && (i%2)==0 ){
100106
zEDate[j++] = aPunct[i/2];
101107
}
102108
zEDate[j++] = zIn[i];
109
+ }
110
+ if( j==10 ){
111
+ memcpy(&zEDate[10], " 23:59:59", 9);
112
+ j += 9;
113
+ }else if( j==16 ){
114
+ memcpy(&zEDate[16], ":59",3);
115
+ j += 3;
103116
}
104117
if( addZulu ){
105
- if( j==10 ){
106
- memcpy(&zEDate[10]," 00:00", 6);
107
- j += 6;
108
- }
109118
zEDate[j++] = 'Z';
110119
}
111120
zEDate[j] = 0;
112121
113122
/* Check for reasonable date values.
114123
--- src/name.c
+++ src/name.c
@@ -58,13 +58,19 @@
58 ** Check to see if the string might be a compact date/time that omits
59 ** the punctuation. Example: "20190327084549" instead of
60 ** "2019-03-27 08:45:49". If the string is of the appropriate form,
61 ** then return an alternative string (in static space) that is the same
62 ** string with punctuation inserted.
 
 
 
 
 
 
63 **
64 ** If the bVerifyNotAHash flag is true, then a check is made to see if
65 ** the string is a hash prefix and NULL is returned if it is. If the
66 ** bVerifyNotAHash flag is false, then the result is determined by syntax
67 ** of the input string only, without reference to the artifact table.
68 */
69 char *fossil_expand_datetime(const char *zIn, int bVerifyNotAHash){
70 static char zEDate[24];
@@ -74,12 +80,12 @@
74 int addZulu = 0;
75
76 /* These forms are allowed:
77 **
78 ** 123456789 1234 123456789 123456789
79 ** (1) YYYYMMDD => YYYY-MM-DD
80 ** (2) YYYYMMDDHHMM => YYYY-MM-DD HH:MM
81 ** (3) YYYYMMDDHHMMSS => YYYY-MM-DD HH:MM:SS
82 **
83 ** An optional "Z" zulu timezone designator is allowed at the end.
84 */
85 if( n>0 && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){
@@ -98,16 +104,19 @@
98 for(i=j=0; i<n; i++){
99 if( i>=4 && (i%2)==0 ){
100 zEDate[j++] = aPunct[i/2];
101 }
102 zEDate[j++] = zIn[i];
 
 
 
 
 
 
 
103 }
104 if( addZulu ){
105 if( j==10 ){
106 memcpy(&zEDate[10]," 00:00", 6);
107 j += 6;
108 }
109 zEDate[j++] = 'Z';
110 }
111 zEDate[j] = 0;
112
113 /* Check for reasonable date values.
114
--- src/name.c
+++ src/name.c
@@ -58,13 +58,19 @@
58 ** Check to see if the string might be a compact date/time that omits
59 ** the punctuation. Example: "20190327084549" instead of
60 ** "2019-03-27 08:45:49". If the string is of the appropriate form,
61 ** then return an alternative string (in static space) that is the same
62 ** string with punctuation inserted.
63 **
64 ** Assume the maximum allowed value for unspecified digits. In other
65 ** words: 202503171234 -> 2025-03-17 12:34:59
66 ** ^^--- Added seconds.
67 ** and: 20250317 -> 2025-03-17 23:59:59
68 ** ^^^^^^^^--- Added time.
69 **
70 ** If the bVerifyNotAHash flag is true, then a check is made to see if
71 ** the input string is a hash prefix and NULL is returned if it is. If the
72 ** bVerifyNotAHash flag is false, then the result is determined by syntax
73 ** of the input string only, without reference to the artifact table.
74 */
75 char *fossil_expand_datetime(const char *zIn, int bVerifyNotAHash){
76 static char zEDate[24];
@@ -74,12 +80,12 @@
80 int addZulu = 0;
81
82 /* These forms are allowed:
83 **
84 ** 123456789 1234 123456789 123456789
85 ** (1) YYYYMMDD => YYYY-MM-DD 23:59:59
86 ** (2) YYYYMMDDHHMM => YYYY-MM-DD HH:MM:59
87 ** (3) YYYYMMDDHHMMSS => YYYY-MM-DD HH:MM:SS
88 **
89 ** An optional "Z" zulu timezone designator is allowed at the end.
90 */
91 if( n>0 && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){
@@ -98,16 +104,19 @@
104 for(i=j=0; i<n; i++){
105 if( i>=4 && (i%2)==0 ){
106 zEDate[j++] = aPunct[i/2];
107 }
108 zEDate[j++] = zIn[i];
109 }
110 if( j==10 ){
111 memcpy(&zEDate[10], " 23:59:59", 9);
112 j += 9;
113 }else if( j==16 ){
114 memcpy(&zEDate[16], ":59",3);
115 j += 3;
116 }
117 if( addZulu ){
 
 
 
 
118 zEDate[j++] = 'Z';
119 }
120 zEDate[j] = 0;
121
122 /* Check for reasonable date values.
123

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button