Fossil

Check-in [515a4d8191]
Login

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

Overview
Comment: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 <=.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 515a4d81917e9f05bb2e61273b4aef282c47bc63b3d58ffc5249acfa1f5f1b25
User & Date: drh 2025-03-17 21:37:51.481
Context
2025-03-18
05:27
Use existing HTTP AUTH information if available when using Fossil configuration synchronization commands. Addresses [forum:d8cb1918f9|forum post d8cb1918f9]. check-in: 5a942d1219 user: andybradford tags: trunk
2025-03-17
21:37
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 <=. check-in: 515a4d8191 user: drh tags: trunk
18:40
Make sure the HTTP really was a POST before logging a "POST from different origin" warning. check-in: 2069259e58 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/name.c.
56
57
58
59
60
61
62
63






64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

/*
** Check to see if the string might be a compact date/time that omits
** the punctuation.  Example:  "20190327084549" instead of
** "2019-03-27 08:45:49".  If the string is of the appropriate form,
** then return an alternative string (in static space) that is the same
** string with punctuation inserted.
**






** If the bVerifyNotAHash flag is true, then a check is made to see if
** the string is a hash prefix and NULL is returned if it is.  If the
** bVerifyNotAHash flag is false, then the result is determined by syntax
** of the input string only, without reference to the artifact table.
*/
char *fossil_expand_datetime(const char *zIn, int bVerifyNotAHash){
  static char zEDate[24];
  static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
  int n = (int)strlen(zIn);
  int i, j;
  int addZulu = 0;

  /* These forms are allowed:
  **
  **        123456789 1234           123456789 123456789
  **   (1)  YYYYMMDD            =>   YYYY-MM-DD
  **   (2)  YYYYMMDDHHMM        =>   YYYY-MM-DD HH:MM
  **   (3)  YYYYMMDDHHMMSS      =>   YYYY-MM-DD HH:MM:SS
  **
  ** An optional "Z" zulu timezone designator is allowed at the end.
  */
  if( n>0 && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){
    n--;
    addZulu = 1;








>
>
>
>
>
>

|













|
|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

/*
** Check to see if the string might be a compact date/time that omits
** the punctuation.  Example:  "20190327084549" instead of
** "2019-03-27 08:45:49".  If the string is of the appropriate form,
** then return an alternative string (in static space) that is the same
** string with punctuation inserted.
**
** Assume the maximum allowed value for unspecified digits.  In other
** words:  202503171234 -> 2025-03-17 12:34:59
**                                          ^^---  Added seconds.
** and: 20250317 -> 2025-03-17 23:59:59
**                             ^^^^^^^^---  Added time.
**
** If the bVerifyNotAHash flag is true, then a check is made to see if
** the input string is a hash prefix and NULL is returned if it is.  If the
** bVerifyNotAHash flag is false, then the result is determined by syntax
** of the input string only, without reference to the artifact table.
*/
char *fossil_expand_datetime(const char *zIn, int bVerifyNotAHash){
  static char zEDate[24];
  static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
  int n = (int)strlen(zIn);
  int i, j;
  int addZulu = 0;

  /* These forms are allowed:
  **
  **        123456789 1234           123456789 123456789
  **   (1)  YYYYMMDD            =>   YYYY-MM-DD 23:59:59
  **   (2)  YYYYMMDDHHMM        =>   YYYY-MM-DD HH:MM:59
  **   (3)  YYYYMMDDHHMMSS      =>   YYYY-MM-DD HH:MM:SS
  **
  ** An optional "Z" zulu timezone designator is allowed at the end.
  */
  if( n>0 && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){
    n--;
    addZulu = 1;
96
97
98
99
100
101
102
103
104
105
106
107



108

109
110
111
112
113
114
115

  /* Expand the date */
  for(i=j=0; i<n; i++){
    if( i>=4 && (i%2)==0 ){
      zEDate[j++] = aPunct[i/2];
    }
    zEDate[j++] = zIn[i];
  }
  if( addZulu ){
    if( j==10 ){
      memcpy(&zEDate[10]," 00:00", 6);
      j += 6;



    }

    zEDate[j++] = 'Z';
  }
  zEDate[j] = 0;

  /* Check for reasonable date values.
  ** Offset references:
  **    YYYY-MM-DD HH:MM:SS








<
|
|
|
>
>
>
|
>







102
103
104
105
106
107
108
109

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

  /* Expand the date */
  for(i=j=0; i<n; i++){
    if( i>=4 && (i%2)==0 ){
      zEDate[j++] = aPunct[i/2];
    }
    zEDate[j++] = zIn[i];
  }

  if( j==10 ){
    memcpy(&zEDate[10], " 23:59:59", 9);
    j += 9;
  }else if( j==16 ){
    memcpy(&zEDate[16], ":59",3);
    j += 3;
  }
  if( addZulu ){
    zEDate[j++] = 'Z';
  }
  zEDate[j] = 0;

  /* Check for reasonable date values.
  ** Offset references:
  **    YYYY-MM-DD HH:MM:SS