Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch subsec-modifier Excluding Merge-Ins
This is equivalent to a diff from 83683e108b to 6499ebff54
2023-05-04
| ||
20:28 | Add the "subsecond" modifier to the date/time functions. (check-in: 6fcb5a941f user: drh tags: trunk) | |
20:19 | Add some tests of subsecond modifier for date/time functions. Sync with trunk. (Closed-Leaf check-in: 6499ebff54 user: larrybr tags: subsec-modifier) | |
14:44 | Enhance the format() function so that the "," modifier works for floating point numbers in addition to integers. (check-in: 83683e108b user: drh tags: trunk) | |
13:07 | Add support for the comma (,) modifier to %f formats in the format() function. (Closed-Leaf check-in: 7080e196a1 user: drh tags: comma-format) | |
11:29 | Fix a bug in cursor hints that can cause references to tables that have not been opened. Cursor hints are intended for use by COMDB2 only and should not appear in production builds, so this should not be a factor for the vast majority of users. (check-in: d3370d59cf user: drh tags: trunk) | |
2023-04-21
| ||
15:30 | Add a new modifier to date/time functions: "subsecond". May be abbreviated as just "subsec". This modifier causes functions to try to show fractional seconds if they do not already. (check-in: 03f2a15e87 user: drh tags: subsec-modifier) | |
Changes to src/date.c.
︙ | |||
73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | + | char validJD; /* True (1) if iJD is valid */ char rawS; /* Raw numeric value stored in s */ char validYMD; /* True (1) if Y,M,D are valid */ char validHMS; /* True (1) if h,m,s are valid */ char validTZ; /* True (1) if tz is valid */ char tzSet; /* Timezone was set explicitly */ char isError; /* An overflow has occurred */ char useSubsec; /* Display subsecond precision */ }; /* ** Convert zDate into one or more integers according to the conversion ** specifier zFormat. ** |
︙ | |||
387 388 389 390 391 392 393 394 395 396 397 398 399 400 | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | + + + + + | }else if( parseHhMmSs(zDate, p)==0 ){ return 0; }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){ return setDateTimeToCurrent(context, p); }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8)>0 ){ setRawDateNumber(p, r); return 0; }else if( (sqlite3StrICmp(zDate,"subsec")==0 || sqlite3StrICmp(zDate,"subsecond")==0) && sqlite3NotPureFunc(context) ){ p->useSubsec = 1; return setDateTimeToCurrent(context, p); } return 1; } /* The julian day number for 9999-12-31 23:59:59.999 is 5373484.4999999. ** Multiplying this by 86400000 gives 464269060799999 as the maximum value ** for DateTime.iJD. |
︙ | |||
801 802 803 804 805 806 807 808 | 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 | + + + + + + - + + + + + + + + + | } case 's': { /* ** start of TTTTT ** ** Move the date backwards to the beginning of the current day, ** or month or year. ** ** subsecond ** subsec ** ** Show subsecond precision in the output of datetime() and ** unixepoch() and strftime('%s'). */ |
︙ | |||
1000 1001 1002 1003 1004 1005 1006 | 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 | + + + - + + - - + + + + + + + + + + + + + - - - - + + + + + + - + - + - + + + + + + + + + + + + - - - - - + + + + + + + | sqlite3_context *context, int argc, sqlite3_value **argv ){ DateTime x; if( isDate(context, argc, argv, &x)==0 ){ computeJD(&x); if( x.useSubsec ){ sqlite3_result_double(context, (x.iJD - 21086676*(i64)10000000)/1000.0); }else{ |
︙ | |||
1207 1208 1209 1210 1211 1212 1213 | 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 | + + + + - - + + + | break; } case 'M': { sqlite3_str_appendf(&sRes,"%02d",x.m); break; } case 's': { if( x.useSubsec ){ sqlite3_str_appendf(&sRes,"%.3f", (x.iJD - 21086676*(i64)10000000)/1000.0); }else{ |
︙ |
Changes to test/date.test.
︙ | |||
540 541 542 543 544 545 546 547 | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | + + + + + + | datetest 17.7 {datetime(38,'start of year')} {-4712-01-01 00:00:00} # 2022-03-04 https://sqlite.org/forum/forumpost/2ffbaa2c3fd7fb82 # The 'localtime' modifier should preserve fractional seconds. # datetest 18.1 {strftime('%f',1.234,'unixepoch','localtime')} {01.234} # 2023-04 The 'subsecond' (or 'subsec') modifier alters resolutions # to at least milliseconds. Added for release 3.42.0 . datetest 18.2 {unixepoch('1970-01-01T00:00:00.1', 'subsec')} {0.1} datetest 18.3 {unixepoch('1970-01-01T00:00:00.2', 'subsecond')} {0.2} datetest 18.4 {julianday('-4713-11-24 13:40:48.864', 'subsec')} {0.07001} datetest 18.5 {typeof(unixepoch('now', 'subsecond'))} {real} finish_test |