Fossil SCM
Move the symbolic_name_to_mtime() routine from timeline.c over to name.c where it belongs. Fix that routine so that the display name omits the rounded up extension to the date/time value.
Commit
54cfac8c8452a3a06e259fc64452cb72d6cfaf9cf145f559d786f076272f28a3
Parent
45965933c288d08…
2 files changed
+56
-1
-52
+56
-1
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -70,11 +70,11 @@ | ||
| 70 | 70 | ** ^^^^--- Added |
| 71 | 71 | ** |
| 72 | 72 | ** 202503171234 -> 2025-03-17 12:34:59.999 |
| 73 | 73 | ** ^^^^^^^--- Added |
| 74 | 74 | ** 20250317 -> 2025-03-17 23:59:59.999 |
| 75 | -** ^^^^^^^^^^^^--- Added | |
| 75 | +** ^^^^^^^^^^^^^--- Added | |
| 76 | 76 | ** |
| 77 | 77 | ** If the bVerifyNotAHash flag is true, then a check is made to see if |
| 78 | 78 | ** the input string is a hash prefix and NULL is returned if it is. If the |
| 79 | 79 | ** bVerifyNotAHash flag is false, then the result is determined by syntax |
| 80 | 80 | ** of the input string only, without reference to the artifact table. |
| @@ -718,10 +718,65 @@ | ||
| 718 | 718 | rid = symbolic_name_to_rid(zNew,zType); |
| 719 | 719 | fossil_free(zNew); |
| 720 | 720 | } |
| 721 | 721 | return rid; |
| 722 | 722 | } |
| 723 | + | |
| 724 | +/* | |
| 725 | +** Convert a symbolic name used as an argument to the a=, b=, or c= | |
| 726 | +** query parameters of timeline into a julianday mtime value. | |
| 727 | +** | |
| 728 | +** If pzDisplay is not null, then display text for the symbolic name might | |
| 729 | +** be written into *pzDisplay. But that is not guaranteed. | |
| 730 | +** | |
| 731 | +** If bRoundUp is true and the symbolic name is a timestamp with less | |
| 732 | +** than millisecond resolution, then the timestamp is rounding up to the | |
| 733 | +** largest millisecond consistent with that timestamp. If bRoundUp is | |
| 734 | +** false, then the resulting time is obtained by extending the timestamp | |
| 735 | +** with zeros (hence rounding down). Use bRoundUp==1 if the result | |
| 736 | +** will be used in mtime<=$RESULT and use bRoundUp==0 if the result | |
| 737 | +** will be used in mtime>=$RESULT. | |
| 738 | +*/ | |
| 739 | +double symbolic_name_to_mtime( | |
| 740 | + const char *z, /* Input symbolic name */ | |
| 741 | + const char **pzDisplay, /* Perhaps write display text here, if not NULL */ | |
| 742 | + int bRoundUp /* Round up if true */ | |
| 743 | +){ | |
| 744 | + double mtime; | |
| 745 | + int rid; | |
| 746 | + const char *zDate; | |
| 747 | + if( z==0 ) return -1.0; | |
| 748 | + if( fossil_isdate(z) ){ | |
| 749 | + mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", z); | |
| 750 | + if( mtime>0.0 ) return mtime; | |
| 751 | + } | |
| 752 | + zDate = fossil_expand_datetime(z, 1, bRoundUp); | |
| 753 | + if( zDate!=0 ){ | |
| 754 | + mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", | |
| 755 | + bRoundUp ? fossil_roundup_date(zDate) : zDate); | |
| 756 | + if( mtime>0.0 ){ | |
| 757 | + if( pzDisplay ){ | |
| 758 | + zDate = fossil_expand_datetime(z,0,0); | |
| 759 | + *pzDisplay = fossil_strdup(zDate); | |
| 760 | + } | |
| 761 | + return mtime; | |
| 762 | + } | |
| 763 | + } | |
| 764 | + rid = symbolic_name_to_rid(z, "*"); | |
| 765 | + if( rid ){ | |
| 766 | + mtime = mtime_of_rid(rid, 0.0); | |
| 767 | + }else{ | |
| 768 | + mtime = db_double(-1.0, | |
| 769 | + "SELECT max(event.mtime) FROM event, tag, tagxref" | |
| 770 | + " WHERE tag.tagname GLOB 'event-%q*'" | |
| 771 | + " AND tagxref.tagid=tag.tagid AND tagxref.tagtype" | |
| 772 | + " AND event.objid=tagxref.rid", | |
| 773 | + z | |
| 774 | + ); | |
| 775 | + } | |
| 776 | + return mtime; | |
| 777 | +} | |
| 723 | 778 | |
| 724 | 779 | /* |
| 725 | 780 | ** This routine takes a user-entered string and tries to convert it to |
| 726 | 781 | ** an artifact hash. |
| 727 | 782 | ** |
| 728 | 783 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -70,11 +70,11 @@ | |
| 70 | ** ^^^^--- Added |
| 71 | ** |
| 72 | ** 202503171234 -> 2025-03-17 12:34:59.999 |
| 73 | ** ^^^^^^^--- Added |
| 74 | ** 20250317 -> 2025-03-17 23:59:59.999 |
| 75 | ** ^^^^^^^^^^^^--- Added |
| 76 | ** |
| 77 | ** If the bVerifyNotAHash flag is true, then a check is made to see if |
| 78 | ** the input string is a hash prefix and NULL is returned if it is. If the |
| 79 | ** bVerifyNotAHash flag is false, then the result is determined by syntax |
| 80 | ** of the input string only, without reference to the artifact table. |
| @@ -718,10 +718,65 @@ | |
| 718 | rid = symbolic_name_to_rid(zNew,zType); |
| 719 | fossil_free(zNew); |
| 720 | } |
| 721 | return rid; |
| 722 | } |
| 723 | |
| 724 | /* |
| 725 | ** This routine takes a user-entered string and tries to convert it to |
| 726 | ** an artifact hash. |
| 727 | ** |
| 728 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -70,11 +70,11 @@ | |
| 70 | ** ^^^^--- Added |
| 71 | ** |
| 72 | ** 202503171234 -> 2025-03-17 12:34:59.999 |
| 73 | ** ^^^^^^^--- Added |
| 74 | ** 20250317 -> 2025-03-17 23:59:59.999 |
| 75 | ** ^^^^^^^^^^^^^--- Added |
| 76 | ** |
| 77 | ** If the bVerifyNotAHash flag is true, then a check is made to see if |
| 78 | ** the input string is a hash prefix and NULL is returned if it is. If the |
| 79 | ** bVerifyNotAHash flag is false, then the result is determined by syntax |
| 80 | ** of the input string only, without reference to the artifact table. |
| @@ -718,10 +718,65 @@ | |
| 718 | rid = symbolic_name_to_rid(zNew,zType); |
| 719 | fossil_free(zNew); |
| 720 | } |
| 721 | return rid; |
| 722 | } |
| 723 | |
| 724 | /* |
| 725 | ** Convert a symbolic name used as an argument to the a=, b=, or c= |
| 726 | ** query parameters of timeline into a julianday mtime value. |
| 727 | ** |
| 728 | ** If pzDisplay is not null, then display text for the symbolic name might |
| 729 | ** be written into *pzDisplay. But that is not guaranteed. |
| 730 | ** |
| 731 | ** If bRoundUp is true and the symbolic name is a timestamp with less |
| 732 | ** than millisecond resolution, then the timestamp is rounding up to the |
| 733 | ** largest millisecond consistent with that timestamp. If bRoundUp is |
| 734 | ** false, then the resulting time is obtained by extending the timestamp |
| 735 | ** with zeros (hence rounding down). Use bRoundUp==1 if the result |
| 736 | ** will be used in mtime<=$RESULT and use bRoundUp==0 if the result |
| 737 | ** will be used in mtime>=$RESULT. |
| 738 | */ |
| 739 | double symbolic_name_to_mtime( |
| 740 | const char *z, /* Input symbolic name */ |
| 741 | const char **pzDisplay, /* Perhaps write display text here, if not NULL */ |
| 742 | int bRoundUp /* Round up if true */ |
| 743 | ){ |
| 744 | double mtime; |
| 745 | int rid; |
| 746 | const char *zDate; |
| 747 | if( z==0 ) return -1.0; |
| 748 | if( fossil_isdate(z) ){ |
| 749 | mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", z); |
| 750 | if( mtime>0.0 ) return mtime; |
| 751 | } |
| 752 | zDate = fossil_expand_datetime(z, 1, bRoundUp); |
| 753 | if( zDate!=0 ){ |
| 754 | mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", |
| 755 | bRoundUp ? fossil_roundup_date(zDate) : zDate); |
| 756 | if( mtime>0.0 ){ |
| 757 | if( pzDisplay ){ |
| 758 | zDate = fossil_expand_datetime(z,0,0); |
| 759 | *pzDisplay = fossil_strdup(zDate); |
| 760 | } |
| 761 | return mtime; |
| 762 | } |
| 763 | } |
| 764 | rid = symbolic_name_to_rid(z, "*"); |
| 765 | if( rid ){ |
| 766 | mtime = mtime_of_rid(rid, 0.0); |
| 767 | }else{ |
| 768 | mtime = db_double(-1.0, |
| 769 | "SELECT max(event.mtime) FROM event, tag, tagxref" |
| 770 | " WHERE tag.tagname GLOB 'event-%q*'" |
| 771 | " AND tagxref.tagid=tag.tagid AND tagxref.tagtype" |
| 772 | " AND event.objid=tagxref.rid", |
| 773 | z |
| 774 | ); |
| 775 | } |
| 776 | return mtime; |
| 777 | } |
| 778 | |
| 779 | /* |
| 780 | ** This routine takes a user-entered string and tries to convert it to |
| 781 | ** an artifact hash. |
| 782 | ** |
| 783 |
-52
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1106,62 +1106,10 @@ | ||
| 1106 | 1106 | @ WHERE blob.rid=event.objid |
| 1107 | 1107 | ; |
| 1108 | 1108 | return zBase; |
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | -/* | |
| 1112 | -** Convert a symbolic name used as an argument to the a=, b=, or c= | |
| 1113 | -** query parameters of timeline into a julianday mtime value. | |
| 1114 | -** | |
| 1115 | -** If pzDisplay is not null, then display text for the symbolic name might | |
| 1116 | -** be written into *pzDisplay. But that is not guaranteed. | |
| 1117 | -** | |
| 1118 | -** If bRoundUp is true and the symbolic name is a timestamp with less | |
| 1119 | -** than millisecond resolution, then the timestamp is rounding up to the | |
| 1120 | -** largest millisecond consistent with that timestamp. If bRoundUp is | |
| 1121 | -** false, then the resulting time is obtained by extending the timestamp | |
| 1122 | -** with zeros (hence rounding down). Use bRoundUp==1 if the result | |
| 1123 | -** will be used in mtime<=$RESULT and use bRoundUp==0 if the result | |
| 1124 | -** will be used in mtime>=$RESULT. | |
| 1125 | -*/ | |
| 1126 | -double symbolic_name_to_mtime( | |
| 1127 | - const char *z, /* Input symbolic name */ | |
| 1128 | - const char **pzDisplay, /* Perhaps write display text here, if not NULL */ | |
| 1129 | - int bRoundUp /* Round up if true */ | |
| 1130 | -){ | |
| 1131 | - double mtime; | |
| 1132 | - int rid; | |
| 1133 | - const char *zDate; | |
| 1134 | - if( z==0 ) return -1.0; | |
| 1135 | - if( fossil_isdate(z) ){ | |
| 1136 | - mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", z); | |
| 1137 | - if( mtime>0.0 ) return mtime; | |
| 1138 | - } | |
| 1139 | - zDate = fossil_expand_datetime(z, 1, bRoundUp); | |
| 1140 | - if( zDate!=0 ){ | |
| 1141 | - mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", | |
| 1142 | - bRoundUp ? fossil_roundup_date(zDate) : zDate); | |
| 1143 | - if( mtime>0.0 ){ | |
| 1144 | - if( pzDisplay ) *pzDisplay = fossil_strdup(zDate); | |
| 1145 | - return mtime; | |
| 1146 | - } | |
| 1147 | - } | |
| 1148 | - rid = symbolic_name_to_rid(z, "*"); | |
| 1149 | - if( rid ){ | |
| 1150 | - mtime = mtime_of_rid(rid, 0.0); | |
| 1151 | - }else{ | |
| 1152 | - mtime = db_double(-1.0, | |
| 1153 | - "SELECT max(event.mtime) FROM event, tag, tagxref" | |
| 1154 | - " WHERE tag.tagname GLOB 'event-%q*'" | |
| 1155 | - " AND tagxref.tagid=tag.tagid AND tagxref.tagtype" | |
| 1156 | - " AND event.objid=tagxref.rid", | |
| 1157 | - z | |
| 1158 | - ); | |
| 1159 | - } | |
| 1160 | - return mtime; | |
| 1161 | -} | |
| 1162 | - | |
| 1163 | 1111 | /* |
| 1164 | 1112 | ** zDate is a localtime date. Insert records into the |
| 1165 | 1113 | ** "timeline" table to cause <hr> to be inserted on zDate. |
| 1166 | 1114 | */ |
| 1167 | 1115 | static int timeline_add_divider(double rDate){ |
| 1168 | 1116 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1106,62 +1106,10 @@ | |
| 1106 | @ WHERE blob.rid=event.objid |
| 1107 | ; |
| 1108 | return zBase; |
| 1109 | } |
| 1110 | |
| 1111 | /* |
| 1112 | ** Convert a symbolic name used as an argument to the a=, b=, or c= |
| 1113 | ** query parameters of timeline into a julianday mtime value. |
| 1114 | ** |
| 1115 | ** If pzDisplay is not null, then display text for the symbolic name might |
| 1116 | ** be written into *pzDisplay. But that is not guaranteed. |
| 1117 | ** |
| 1118 | ** If bRoundUp is true and the symbolic name is a timestamp with less |
| 1119 | ** than millisecond resolution, then the timestamp is rounding up to the |
| 1120 | ** largest millisecond consistent with that timestamp. If bRoundUp is |
| 1121 | ** false, then the resulting time is obtained by extending the timestamp |
| 1122 | ** with zeros (hence rounding down). Use bRoundUp==1 if the result |
| 1123 | ** will be used in mtime<=$RESULT and use bRoundUp==0 if the result |
| 1124 | ** will be used in mtime>=$RESULT. |
| 1125 | */ |
| 1126 | double symbolic_name_to_mtime( |
| 1127 | const char *z, /* Input symbolic name */ |
| 1128 | const char **pzDisplay, /* Perhaps write display text here, if not NULL */ |
| 1129 | int bRoundUp /* Round up if true */ |
| 1130 | ){ |
| 1131 | double mtime; |
| 1132 | int rid; |
| 1133 | const char *zDate; |
| 1134 | if( z==0 ) return -1.0; |
| 1135 | if( fossil_isdate(z) ){ |
| 1136 | mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", z); |
| 1137 | if( mtime>0.0 ) return mtime; |
| 1138 | } |
| 1139 | zDate = fossil_expand_datetime(z, 1, bRoundUp); |
| 1140 | if( zDate!=0 ){ |
| 1141 | mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", |
| 1142 | bRoundUp ? fossil_roundup_date(zDate) : zDate); |
| 1143 | if( mtime>0.0 ){ |
| 1144 | if( pzDisplay ) *pzDisplay = fossil_strdup(zDate); |
| 1145 | return mtime; |
| 1146 | } |
| 1147 | } |
| 1148 | rid = symbolic_name_to_rid(z, "*"); |
| 1149 | if( rid ){ |
| 1150 | mtime = mtime_of_rid(rid, 0.0); |
| 1151 | }else{ |
| 1152 | mtime = db_double(-1.0, |
| 1153 | "SELECT max(event.mtime) FROM event, tag, tagxref" |
| 1154 | " WHERE tag.tagname GLOB 'event-%q*'" |
| 1155 | " AND tagxref.tagid=tag.tagid AND tagxref.tagtype" |
| 1156 | " AND event.objid=tagxref.rid", |
| 1157 | z |
| 1158 | ); |
| 1159 | } |
| 1160 | return mtime; |
| 1161 | } |
| 1162 | |
| 1163 | /* |
| 1164 | ** zDate is a localtime date. Insert records into the |
| 1165 | ** "timeline" table to cause <hr> to be inserted on zDate. |
| 1166 | */ |
| 1167 | static int timeline_add_divider(double rDate){ |
| 1168 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1106,62 +1106,10 @@ | |
| 1106 | @ WHERE blob.rid=event.objid |
| 1107 | ; |
| 1108 | return zBase; |
| 1109 | } |
| 1110 | |
| 1111 | /* |
| 1112 | ** zDate is a localtime date. Insert records into the |
| 1113 | ** "timeline" table to cause <hr> to be inserted on zDate. |
| 1114 | */ |
| 1115 | static int timeline_add_divider(double rDate){ |
| 1116 |