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 <=.
Commit
515a4d81917e9f05bb2e61273b4aef282c47bc63b3d58ffc5249acfa1f5f1b25
Parent
2069259e583c533…
1 file changed
+16
-7
+16
-7
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -58,13 +58,19 @@ | ||
| 58 | 58 | ** Check to see if the string might be a compact date/time that omits |
| 59 | 59 | ** the punctuation. Example: "20190327084549" instead of |
| 60 | 60 | ** "2019-03-27 08:45:49". If the string is of the appropriate form, |
| 61 | 61 | ** then return an alternative string (in static space) that is the same |
| 62 | 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. | |
| 63 | 69 | ** |
| 64 | 70 | ** 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 | |
| 66 | 72 | ** bVerifyNotAHash flag is false, then the result is determined by syntax |
| 67 | 73 | ** of the input string only, without reference to the artifact table. |
| 68 | 74 | */ |
| 69 | 75 | char *fossil_expand_datetime(const char *zIn, int bVerifyNotAHash){ |
| 70 | 76 | static char zEDate[24]; |
| @@ -74,12 +80,12 @@ | ||
| 74 | 80 | int addZulu = 0; |
| 75 | 81 | |
| 76 | 82 | /* These forms are allowed: |
| 77 | 83 | ** |
| 78 | 84 | ** 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 | |
| 81 | 87 | ** (3) YYYYMMDDHHMMSS => YYYY-MM-DD HH:MM:SS |
| 82 | 88 | ** |
| 83 | 89 | ** An optional "Z" zulu timezone designator is allowed at the end. |
| 84 | 90 | */ |
| 85 | 91 | if( n>0 && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){ |
| @@ -98,16 +104,19 @@ | ||
| 98 | 104 | for(i=j=0; i<n; i++){ |
| 99 | 105 | if( i>=4 && (i%2)==0 ){ |
| 100 | 106 | zEDate[j++] = aPunct[i/2]; |
| 101 | 107 | } |
| 102 | 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; | |
| 103 | 116 | } |
| 104 | 117 | if( addZulu ){ |
| 105 | - if( j==10 ){ | |
| 106 | - memcpy(&zEDate[10]," 00:00", 6); | |
| 107 | - j += 6; | |
| 108 | - } | |
| 109 | 118 | zEDate[j++] = 'Z'; |
| 110 | 119 | } |
| 111 | 120 | zEDate[j] = 0; |
| 112 | 121 | |
| 113 | 122 | /* Check for reasonable date values. |
| 114 | 123 |
| --- 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 |