OpenCoverage

date.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/sqlite/src/src/date.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3typedef struct DateTime DateTime;-
4struct DateTime {-
5 sqlite3_int64 iJD;-
6 int Y, M, D;-
7 int h, m;-
8 int tz;-
9 double s;-
10 char validJD;-
11 char rawS;-
12 char validYMD;-
13 char validHMS;-
14 char validTZ;-
15 char tzSet;-
16 char isError;-
17};-
18static int getDigits(const char *zDate, const char *zFormat, ...){-
19-
20-
21 static const u16 aMx[] = { 12, 14, 24, 31, 59, 9999 };-
22 va_list ap;-
23 int cnt = 0;-
24 char nextC;-
25 -
26 __builtin_va_start(-
27 ap-
28 ,-
29 zFormat-
30 )-
31 ;-
32 do{-
33 char N = zFormat[0] - '0';-
34 char min = zFormat[1] - '0';-
35 int val = 0;-
36 u16 max;-
37-
38 -
39 ((void) (0))-
40 ;-
41 max = aMx[zFormat[2] - 'a'];-
42 nextC = zFormat[3];-
43 val = 0;-
44 while( N--
N--Description
TRUEevaluated 2898 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1098 times by 1 test
Evaluated by:
  • Self test (438)
){
1098-2898
45 if( !(sqlite3CtypeMap[(unsigned char)(*zDate)]&0x04)
!(sqlite3Ctype...*zDate)]&0x04)Description
TRUEevaluated 213 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2685 times by 1 test
Evaluated by:
  • Self test (438)
){
213-2685
46 goto
executed 213 times by 1 test: goto end_getDigits;
Executed by:
  • Self test (438)
end_getDigits;
executed 213 times by 1 test: goto end_getDigits;
Executed by:
  • Self test (438)
213
47 }-
48 val = val*10 + *zDate - '0';-
49 zDate++;-
50 }
executed 2685 times by 1 test: end of block
Executed by:
  • Self test (438)
2685
51 if( val<(int)min
val<(int)minDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1096 times by 1 test
Evaluated by:
  • Self test (438)
|| val>(int)max
val>(int)maxDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1089 times by 1 test
Evaluated by:
  • Self test (438)
|| (nextC!=0
nextC!=0Description
TRUEevaluated 632 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 457 times by 1 test
Evaluated by:
  • Self test (438)
&& nextC!=*zDate
nextC!=*zDateDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 612 times by 1 test
Evaluated by:
  • Self test (438)
) ){
2-1096
52 goto
executed 29 times by 1 test: goto end_getDigits;
Executed by:
  • Self test (438)
end_getDigits;
executed 29 times by 1 test: goto end_getDigits;
Executed by:
  • Self test (438)
29
53 }-
54 *-
55 __builtin_va_arg(-
56 ap-
57 ,-
58 int*-
59 ) -
60 = val;-
61 zDate++;-
62 cnt++;-
63 zFormat += 4;-
64 }
executed 1069 times by 1 test: end of block
Executed by:
  • Self test (438)
while( nextC
nextCDescription
TRUEevaluated 612 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 457 times by 1 test
Evaluated by:
  • Self test (438)
);
457-1069
65end_getDigits:
code before this statement executed 457 times by 1 test: end_getDigits:
Executed by:
  • Self test (438)
457
66 -
67 __builtin_va_end(-
68 ap-
69 )-
70 ;-
71 return
executed 699 times by 1 test: return cnt;
Executed by:
  • Self test (438)
cnt;
executed 699 times by 1 test: return cnt;
Executed by:
  • Self test (438)
699
72}-
73static int parseTimezone(const char *zDate, DateTime *p){-
74 int sgn = 0;-
75 int nHr, nMn;-
76 int c;-
77 while( (
(sqlite3CtypeM...*zDate)]&0x01)Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 134 times by 1 test
Evaluated by:
  • Self test (438)
sqlite3CtypeMap[(unsigned char)(*zDate)]&0x01)
(sqlite3CtypeM...*zDate)]&0x01)Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 134 times by 1 test
Evaluated by:
  • Self test (438)
){ zDate++; }
executed 15 times by 1 test: end of block
Executed by:
  • Self test (438)
15-134
78 p->tz = 0;-
79 c = *zDate;-
80 if( c=='-'
c=='-'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 129 times by 1 test
Evaluated by:
  • Self test (438)
){
5-129
81 sgn = -1;-
82 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test (438)
else if( c=='+'
c=='+'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 126 times by 1 test
Evaluated by:
  • Self test (438)
){
3-126
83 sgn = +1;-
84 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test (438)
else if( c=='Z'
c=='Z'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 122 times by 1 test
Evaluated by:
  • Self test (438)
|| c=='z'
c=='z'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 119 times by 1 test
Evaluated by:
  • Self test (438)
){
3-122
85 zDate++;-
86 goto
executed 7 times by 1 test: goto zulu_time;
Executed by:
  • Self test (438)
zulu_time;
executed 7 times by 1 test: goto zulu_time;
Executed by:
  • Self test (438)
7
87 }else{-
88 return
executed 119 times by 1 test: return c!=0;
Executed by:
  • Self test (438)
c!=0;
executed 119 times by 1 test: return c!=0;
Executed by:
  • Self test (438)
119
89 }-
90 zDate++;-
91 if( getDigits(zDate, "20b:20e", &nHr, &nMn)!=2
getDigits(zDat...&nHr, &nMn)!=2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test (438)
){
1-7
92 return
executed 1 time by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 1 time by 1 test: return 1;
Executed by:
  • Self test (438)
1
93 }-
94 zDate += 5;-
95 p->tz = sgn*(nMn + nHr*60);-
96zulu_time:
code before this statement executed 7 times by 1 test: zulu_time:
Executed by:
  • Self test (438)
7
97 while( (
(sqlite3CtypeM...*zDate)]&0x01)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
sqlite3CtypeMap[(unsigned char)(*zDate)]&0x01)
(sqlite3CtypeM...*zDate)]&0x01)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
){ zDate++; }
executed 13 times by 1 test: end of block
Executed by:
  • Self test (438)
13-14
98 p->tzSet = 1;-
99 return
executed 14 times by 1 test: return *zDate!=0;
Executed by:
  • Self test (438)
*zDate!=0;
executed 14 times by 1 test: return *zDate!=0;
Executed by:
  • Self test (438)
14
100}-
101static int parseHhMmSs(const char *zDate, DateTime *p){-
102 int h, m, s;-
103 double ms = 0.0;-
104 if( getDigits(zDate, "20c:20e", &h, &m)!=2
getDigits(zDat...e", &h, &m)!=2Description
TRUEevaluated 177 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 135 times by 1 test
Evaluated by:
  • Self test (438)
){
135-177
105 return
executed 177 times by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 177 times by 1 test: return 1;
Executed by:
  • Self test (438)
177
106 }-
107 zDate += 5;-
108 if( *
*zDate==':'Description
TRUEevaluated 87 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 48 times by 1 test
Evaluated by:
  • Self test (438)
zDate==':'
*zDate==':'Description
TRUEevaluated 87 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 48 times by 1 test
Evaluated by:
  • Self test (438)
){
48-87
109 zDate++;-
110 if( getDigits(zDate, "20e", &s)!=1
getDigits(zDate, "20e", &s)!=1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 86 times by 1 test
Evaluated by:
  • Self test (438)
){
1-86
111 return
executed 1 time by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 1 time by 1 test: return 1;
Executed by:
  • Self test (438)
1
112 }-
113 zDate += 2;-
114 if( *
*zDate=='.'Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 57 times by 1 test
Evaluated by:
  • Self test (438)
zDate=='.'
*zDate=='.'Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 57 times by 1 test
Evaluated by:
  • Self test (438)
&& (
(sqlite3CtypeM...ate[1])]&0x04)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
sqlite3CtypeMap[(unsigned char)(zDate[1])]&0x04)
(sqlite3CtypeM...ate[1])]&0x04)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
){
1-57
115 double rScale = 1.0;-
116 zDate++;-
117 while( (
(sqlite3CtypeM...*zDate)]&0x04)Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
sqlite3CtypeMap[(unsigned char)(*zDate)]&0x04)
(sqlite3CtypeM...*zDate)]&0x04)Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
){
28-72
118 ms = ms*10.0 + *zDate - '0';-
119 rScale *= 10.0;-
120 zDate++;-
121 }
executed 72 times by 1 test: end of block
Executed by:
  • Self test (438)
72
122 ms /= rScale;-
123 }
executed 28 times by 1 test: end of block
Executed by:
  • Self test (438)
28
124 }
executed 86 times by 1 test: end of block
Executed by:
  • Self test (438)
else{
86
125 s = 0;-
126 }
executed 48 times by 1 test: end of block
Executed by:
  • Self test (438)
48
127 p->validJD = 0;-
128 p->rawS = 0;-
129 p->validHMS = 1;-
130 p->h = h;-
131 p->m = m;-
132 p->s = s + ms;-
133 if( parseTimezone(zDate, p)
parseTimezone(zDate, p)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 127 times by 1 test
Evaluated by:
  • Self test (438)
) return
executed 7 times by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 7 times by 1 test: return 1;
Executed by:
  • Self test (438)
7-127
134 p->validTZ = (
(p->tz!=0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 122 times by 1 test
Evaluated by:
  • Self test (438)
p->tz!=0)
(p->tz!=0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 122 times by 1 test
Evaluated by:
  • Self test (438)
?1:0;
5-122
135 return
executed 127 times by 1 test: return 0;
Executed by:
  • Self test (438)
0;
executed 127 times by 1 test: return 0;
Executed by:
  • Self test (438)
127
136}-
137-
138-
139-
140-
141static void datetimeError(DateTime *p){-
142 memset(p, 0, sizeof(*p));-
143 p->isError = 1;-
144}
executed 1 time by 1 test: end of block
Executed by:
  • Self test (438)
1
145-
146-
147-
148-
149-
150-
151-
152static void computeJD(DateTime *p){-
153 int Y, M, D, A, B, X1, X2;-
154-
155 if( p->validJD
p->validJDDescription
TRUEevaluated 8804 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 377 times by 1 test
Evaluated by:
  • Self test (438)
) return;
executed 8804 times by 1 test: return;
Executed by:
  • Self test (438)
377-8804
156 if( p->validYMD
p->validYMDDescription
TRUEevaluated 362 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test (438)
){
15-362
157 Y = p->Y;-
158 M = p->M;-
159 D = p->D;-
160 }
executed 362 times by 1 test: end of block
Executed by:
  • Self test (438)
else{
362
161 Y = 2000;-
162 M = 1;-
163 D = 1;-
164 }
executed 15 times by 1 test: end of block
Executed by:
  • Self test (438)
15
165 if( Y<-4713
Y<-4713Description
TRUEnever evaluated
FALSEevaluated 377 times by 1 test
Evaluated by:
  • Self test (438)
|| Y>9999
Y>9999Description
TRUEnever evaluated
FALSEevaluated 377 times by 1 test
Evaluated by:
  • Self test (438)
|| p->rawS
p->rawSDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 376 times by 1 test
Evaluated by:
  • Self test (438)
){
0-377
166 datetimeError(p);-
167 return;
executed 1 time by 1 test: return;
Executed by:
  • Self test (438)
1
168 }-
169 if( M<=2
M<=2Description
TRUEevaluated 145 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 231 times by 1 test
Evaluated by:
  • Self test (438)
){
145-231
170 Y--;-
171 M += 12;-
172 }
executed 145 times by 1 test: end of block
Executed by:
  • Self test (438)
145
173 A = Y/100;-
174 B = 2 - A + (A/4);-
175 X1 = 36525*(Y+4716)/100;-
176 X2 = 306001*(M+1)/10000;-
177 p->iJD = (sqlite3_int64)((X1 + X2 + D + B - 1524.5 ) * 86400000);-
178 p->validJD = 1;-
179 if( p->validHMS
p->validHMSDescription
TRUEevaluated 279 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 97 times by 1 test
Evaluated by:
  • Self test (438)
){
97-279
180 p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000);-
181 if( p->validTZ
p->validTZDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 274 times by 1 test
Evaluated by:
  • Self test (438)
){
5-274
182 p->iJD -= p->tz*60000;-
183 p->validYMD = 0;-
184 p->validHMS = 0;-
185 p->validTZ = 0;-
186 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test (438)
5
187 }
executed 279 times by 1 test: end of block
Executed by:
  • Self test (438)
279
188}
executed 376 times by 1 test: end of block
Executed by:
  • Self test (438)
376
189static int parseYyyyMmDd(const char *zDate, DateTime *p){-
190 int Y, M, D, neg;-
191-
192 if( zDate[0]=='-'
zDate[0]=='-'Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 284 times by 1 test
Evaluated by:
  • Self test (438)
){
8-284
193 zDate++;-
194 neg = 1;-
195 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test (438)
else{
8
196 neg = 0;-
197 }
executed 284 times by 1 test: end of block
Executed by:
  • Self test (438)
284
198 if( getDigits(zDate, "40f-21a-21d", &Y, &M, &D)!=3
getDigits(zDat...&Y, &M, &D)!=3Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 229 times by 1 test
Evaluated by:
  • Self test (438)
){
63-229
199 return
executed 63 times by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 63 times by 1 test: return 1;
Executed by:
  • Self test (438)
63
200 }-
201 zDate += 10;-
202 while( (
(sqlite3CtypeM...*zDate)]&0x01)Description
TRUEevaluated 125 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 235 times by 1 test
Evaluated by:
  • Self test (438)
sqlite3CtypeMap[(unsigned char)(*zDate)]&0x01)
(sqlite3CtypeM...*zDate)]&0x01)Description
TRUEevaluated 125 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 235 times by 1 test
Evaluated by:
  • Self test (438)
|| 'T'==*(u8*)zDate
'T'==*(u8*)zDateDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 229 times by 1 test
Evaluated by:
  • Self test (438)
){ zDate++; }
executed 131 times by 1 test: end of block
Executed by:
  • Self test (438)
6-235
203 if( parseHhMmSs(zDate, p)==0
parseHhMmSs(zDate, p)==0Description
TRUEevaluated 113 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 116 times by 1 test
Evaluated by:
  • Self test (438)
){
113-116
204-
205 }
executed 113 times by 1 test: end of block
Executed by:
  • Self test (438)
else if( *
*zDate==0Description
TRUEevaluated 106 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
zDate==0
*zDate==0Description
TRUEevaluated 106 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
){
10-113
206 p->validHMS = 0;-
207 }
executed 106 times by 1 test: end of block
Executed by:
  • Self test (438)
else{
106
208 return
executed 10 times by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 10 times by 1 test: return 1;
Executed by:
  • Self test (438)
10
209 }-
210 p->validJD = 0;-
211 p->validYMD = 1;-
212 p->Y = neg
negDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 211 times by 1 test
Evaluated by:
  • Self test (438)
? -Y : Y;
8-211
213 p->M = M;-
214 p->D = D;-
215 if( p->validTZ
p->validTZDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 214 times by 1 test
Evaluated by:
  • Self test (438)
){
5-214
216 computeJD(p);-
217 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test (438)
5
218 return
executed 219 times by 1 test: return 0;
Executed by:
  • Self test (438)
0;
executed 219 times by 1 test: return 0;
Executed by:
  • Self test (438)
219
219}-
220-
221-
222-
223-
224-
225-
226static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){-
227 p->iJD = sqlite3StmtCurrentTime(context);-
228 if( p->iJD>0
p->iJD>0Description
TRUEevaluated 78 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
){
0-78
229 p->validJD = 1;-
230 return
executed 78 times by 1 test: return 0;
Executed by:
  • Self test (438)
0;
executed 78 times by 1 test: return 0;
Executed by:
  • Self test (438)
78
231 }else{-
232 return
never executed: return 1;
1;
never executed: return 1;
0
233 }-
234}-
235-
236-
237-
238-
239-
240-
241-
242static void setRawDateNumber(DateTime *p, double r){-
243 p->s = r;-
244 p->rawS = 1;-
245 if( r>=0.0
r>=0.0Description
TRUEevaluated 4414 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
&& r<5373484.5
r<5373484.5Description
TRUEevaluated 3408 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1006 times by 1 test
Evaluated by:
  • Self test (438)
){
0-4414
246 p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5);-
247 p->validJD = 1;-
248 }
executed 3408 times by 1 test: end of block
Executed by:
  • Self test (438)
3408
249}
executed 4414 times by 1 test: end of block
Executed by:
  • Self test (438)
4414
250static int parseDateOrTime(-
251 sqlite3_context *context,-
252 const char *zDate,-
253 DateTime *p-
254){-
255 double r;-
256 if( parseYyyyMmDd(zDate,p)==0
parseYyyyMmDd(zDate,p)==0Description
TRUEevaluated 219 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 73 times by 1 test
Evaluated by:
  • Self test (438)
){
73-219
257 return
executed 219 times by 1 test: return 0;
Executed by:
  • Self test (438)
0;
executed 219 times by 1 test: return 0;
Executed by:
  • Self test (438)
219
258 }else if( parseHhMmSs(zDate, p)==0
parseHhMmSs(zDate, p)==0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test (438)
){
5-68
259 return
executed 5 times by 1 test: return 0;
Executed by:
  • Self test (438)
0;
executed 5 times by 1 test: return 0;
Executed by:
  • Self test (438)
5
260 }else if( sqlite3StrICmp(zDate,"now")==0
sqlite3StrICmp(zDate,"now")==0Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test (438)
&& sqlite3NotPureFunc(context)
sqlite3NotPureFunc(context)Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
){
6-46
261 return
executed 40 times by 1 test: return setDateTimeToCurrent(context, p);
Executed by:
  • Self test (438)
setDateTimeToCurrent(context, p);
executed 40 times by 1 test: return setDateTimeToCurrent(context, p);
Executed by:
  • Self test (438)
40
262 }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), 1)
sqlite3AtoF(zD...n30(zDate), 1)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 26 times by 1 test
Evaluated by:
  • Self test (438)
){
2-26
263 setRawDateNumber(p, r);-
264 return
executed 2 times by 1 test: return 0;
Executed by:
  • Self test (438)
0;
executed 2 times by 1 test: return 0;
Executed by:
  • Self test (438)
2
265 }-
266 return
executed 26 times by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 26 times by 1 test: return 1;
Executed by:
  • Self test (438)
26
267}-
268static int validJulianDay(sqlite3_int64 iJD){-
269 return
executed 9168 times by 1 test: return iJD>=0 && iJD<=((((i64)0x1a640)<<32)|0x1072fdff);
Executed by:
  • Self test (438)
iJD>=0
iJD>=0Description
TRUEevaluated 9167 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
&& iJD<=((((i64)0x1a640)<<32)|0x1072fdff)
iJD<=((((i64)0...2)|0x1072fdff)Description
TRUEevaluated 9167 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
;
executed 9168 times by 1 test: return iJD>=0 && iJD<=((((i64)0x1a640)<<32)|0x1072fdff);
Executed by:
  • Self test (438)
0-9168
270}-
271-
272-
273-
274-
275static void computeYMD(DateTime *p){-
276 int Z, A, B, C, D, E, X1;-
277 if( p->validYMD
p->validYMDDescription
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4544 times by 1 test
Evaluated by:
  • Self test (438)
) return;
executed 108 times by 1 test: return;
Executed by:
  • Self test (438)
108-4544
278 if( !p->validJD
!p->validJDDescription
TRUEnever evaluated
FALSEevaluated 4544 times by 1 test
Evaluated by:
  • Self test (438)
){
0-4544
279 p->Y = 2000;-
280 p->M = 1;-
281 p->D = 1;-
282 }
never executed: end of block
else if( !validJulianDay(p->iJD)
!validJulianDay(p->iJD)Description
TRUEnever evaluated
FALSEevaluated 4544 times by 1 test
Evaluated by:
  • Self test (438)
){
0-4544
283 datetimeError(p);-
284 return;
never executed: return;
0
285 }else{-
286 Z = (int)((p->iJD + 43200000)/86400000);-
287 A = (int)((Z - 1867216.25)/36524.25);-
288 A = Z + 1 + A - (A/4);-
289 B = A + 1524;-
290 C = (int)((B - 122.1)/365.25);-
291 D = (36525*(C&32767))/100;-
292 E = (int)((B-D)/30.6001);-
293 X1 = (int)(30.6001*E);-
294 p->D = B - D - X1;-
295 p->M = E<14
E<14Description
TRUEevaluated 4011 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 533 times by 1 test
Evaluated by:
  • Self test (438)
? E-1 : E-13;
533-4011
296 p->Y = p->M>2
p->M>2Description
TRUEevaluated 4011 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 533 times by 1 test
Evaluated by:
  • Self test (438)
? C - 4716 : C - 4715;
533-4011
297 }
executed 4544 times by 1 test: end of block
Executed by:
  • Self test (438)
4544
298 p->validYMD = 1;-
299}
executed 4544 times by 1 test: end of block
Executed by:
  • Self test (438)
4544
300-
301-
302-
303-
304static void computeHMS(DateTime *p){-
305 int s;-
306 if( p->validHMS
p->validHMSDescription
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3037 times by 1 test
Evaluated by:
  • Self test (438)
) return;
executed 72 times by 1 test: return;
Executed by:
  • Self test (438)
72-3037
307 computeJD(p);-
308 s = (int)((p->iJD + 43200000) % 86400000);-
309 p->s = s/1000.0;-
310 s = (int)p->s;-
311 p->s -= s;-
312 p->h = s/3600;-
313 s -= p->h*3600;-
314 p->m = s/60;-
315 p->s += s - p->m*60;-
316 p->rawS = 0;-
317 p->validHMS = 1;-
318}
executed 3037 times by 1 test: end of block
Executed by:
  • Self test (438)
3037
319-
320-
321-
322-
323static void computeYMD_HMS(DateTime *p){-
324 computeYMD(p);-
325 computeHMS(p);-
326}
executed 3095 times by 1 test: end of block
Executed by:
  • Self test (438)
3095
327-
328-
329-
330-
331static void clearYMD_HMS_TZ(DateTime *p){-
332 p->validYMD = 0;-
333 p->validHMS = 0;-
334 p->validTZ = 0;-
335}
executed 1199 times by 1 test: end of block
Executed by:
  • Self test (438)
1199
336static int osLocaltime(time_t *t, struct tm *pTm){-
337 int rc;-
338 if( sqlite3Config.bLocaltimeFault
sqlite3Config.bLocaltimeFaultDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test (438)
) return
executed 2 times by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 2 times by 1 test: return 1;
Executed by:
  • Self test (438)
2-16
339-
340-
341 rc = localtime_r(t, pTm)==0;-
342-
343-
344-
345-
346 return
executed 16 times by 1 test: return rc;
Executed by:
  • Self test (438)
rc;
executed 16 times by 1 test: return rc;
Executed by:
  • Self test (438)
16
347}-
348static sqlite3_int64 localtimeOffset(-
349 DateTime *p,-
350 sqlite3_context *pCtx,-
351 int *pRc-
352){-
353 DateTime x, y;-
354 time_t t;-
355 struct tm sLocal;-
356-
357-
358 memset(&sLocal, 0, sizeof(sLocal));-
359-
360 x = *p;-
361 computeYMD_HMS(&x);-
362 if( x.Y<1971
x.Y<1971Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test (438)
|| x.Y>=2038
x.Y>=2038Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test (438)
){
0-18
363-
364-
365-
366-
367-
368 x.Y = 2000;-
369 x.M = 1;-
370 x.D = 1;-
371 x.h = 0;-
372 x.m = 0;-
373 x.s = 0.0;-
374 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test (438)
else {
3
375 int s = (int)(x.s + 0.5);-
376 x.s = s;-
377 }
executed 15 times by 1 test: end of block
Executed by:
  • Self test (438)
15
378 x.tz = 0;-
379 x.validJD = 0;-
380 computeJD(&x);-
381 t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);-
382 if( osLocaltime(&t, &sLocal)
osLocaltime(&t, &sLocal)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test (438)
){
2-16
383 sqlite3_result_error(pCtx, "local time unavailable", -1);-
384 *pRc = 1;-
385 return
executed 2 times by 1 test: return 0;
Executed by:
  • Self test (438)
0;
executed 2 times by 1 test: return 0;
Executed by:
  • Self test (438)
2
386 }-
387 y.Y = sLocal.tm_year + 1900;-
388 y.M = sLocal.tm_mon + 1;-
389 y.D = sLocal.tm_mday;-
390 y.h = sLocal.tm_hour;-
391 y.m = sLocal.tm_min;-
392 y.s = sLocal.tm_sec;-
393 y.validYMD = 1;-
394 y.validHMS = 1;-
395 y.validJD = 0;-
396 y.rawS = 0;-
397 y.validTZ = 0;-
398 y.isError = 0;-
399 computeJD(&y);-
400 *pRc = 0;-
401 return
executed 16 times by 1 test: return y.iJD - x.iJD;
Executed by:
  • Self test (438)
y.iJD - x.iJD;
executed 16 times by 1 test: return y.iJD - x.iJD;
Executed by:
  • Self test (438)
16
402}-
403static const struct {-
404 u8 eType;-
405 u8 nName;-
406 char *zName;-
407 double rLimit;-
408 double rXform;-
409} aXformType[] = {-
410 { 0, 6, "second", 464269060800.0, 86400000.0/(24.0*60.0*60.0) },-
411 { 0, 6, "minute", 7737817680.0, 86400000.0/(24.0*60.0) },-
412 { 0, 4, "hour", 128963628.0, 86400000.0/24.0 },-
413 { 0, 3, "day", 5373485.0, 86400000.0 },-
414 { 1, 5, "month", 176546.0, 30.0*86400000.0 },-
415 { 2, 4, "year", 14713.0, 365.0*86400000.0 },-
416};-
417static int parseModifier(-
418 sqlite3_context *pCtx,-
419 const char *z,-
420 int n,-
421 DateTime *p-
422){-
423 int rc = 1;-
424 double r;-
425 switch(sqlite3UpperToLower[(u8)z[0]] ){-
426-
427 case
executed 14 times by 1 test: case 'l':
Executed by:
  • Self test (438)
'l':
executed 14 times by 1 test: case 'l':
Executed by:
  • Self test (438)
{
14
428-
429-
430-
431-
432-
433 if( sqlite3_stricmp(z, "localtime")==0
sqlite3_stricm...localtime")==0Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
&& sqlite3NotPureFunc(pCtx)
sqlite3NotPureFunc(pCtx)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
){
0-14
434 computeJD(p);-
435 p->iJD += localtimeOffset(p, pCtx, &rc);-
436 clearYMD_HMS_TZ(p);-
437 }
executed 13 times by 1 test: end of block
Executed by:
  • Self test (438)
13
438 break;
executed 14 times by 1 test: break;
Executed by:
  • Self test (438)
14
439 }-
440-
441 case
executed 1018 times by 1 test: case 'u':
Executed by:
  • Self test (438)
'u':
executed 1018 times by 1 test: case 'u':
Executed by:
  • Self test (438)
{
1018
442-
443-
444-
445-
446-
447-
448 if( sqlite3_stricmp(z, "unixepoch")==0
sqlite3_stricm...unixepoch")==0Description
TRUEevaluated 1012 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
&& p->rawS
p->rawSDescription
TRUEevaluated 1011 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
){
1-1012
449 r = p->s*1000.0 + 210866760000000.0;-
450 if( r>=0.0
r>=0.0Description
TRUEevaluated 1011 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
&& r<464269060800000.0
r<464269060800000.0Description
TRUEevaluated 1011 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
){
0-1011
451 clearYMD_HMS_TZ(p);-
452 p->iJD = (sqlite3_int64)r;-
453 p->validJD = 1;-
454 p->rawS = 0;-
455 rc = 0;-
456 }
executed 1011 times by 1 test: end of block
Executed by:
  • Self test (438)
1011
457 }
executed 1011 times by 1 test: end of block
Executed by:
  • Self test (438)
1011
458-
459 else if( sqlite3_stricmp(z, "utc")==0
sqlite3_stricmp(z, "utc")==0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
&& sqlite3NotPureFunc(pCtx)
sqlite3NotPureFunc(pCtx)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
){
1-4
460 if( p->tzSet==0
p->tzSet==0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
){
0-3
461 sqlite3_int64 c1;-
462 computeJD(p);-
463 c1 = localtimeOffset(p, pCtx, &rc);-
464 if( rc==0
rc==0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
){
1-2
465 p->iJD -= c1;-
466 clearYMD_HMS_TZ(p);-
467 p->iJD += c1 - localtimeOffset(p, pCtx, &rc);-
468 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test (438)
2
469 p->tzSet = 1;-
470 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test (438)
else{
3
471 rc = 0;-
472 }
never executed: end of block
0
473 }-
474-
475 break;
executed 1018 times by 1 test: break;
Executed by:
  • Self test (438)
1018
476 }-
477 case
executed 24 times by 1 test: case 'w':
Executed by:
  • Self test (438)
'w':
executed 24 times by 1 test: case 'w':
Executed by:
  • Self test (438)
{
24
478-
479-
480-
481-
482-
483-
484-
485 if( sqlite3_strnicmp(z, "weekday ", 8)==0
sqlite3_strnic...ekday ", 8)==0Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-23
486 && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), 1)
sqlite3AtoF(&z...n30(&z[8]), 1)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-21
487 && (
(n=(int)r)==rDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
n=(int)r)==r
(n=(int)r)==rDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
&& n>=0
n>=0Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
&& r<7
r<7Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
){
1-20
488 sqlite3_int64 Z;-
489 computeYMD_HMS(p);-
490 p->validTZ = 0;-
491 p->validJD = 0;-
492 computeJD(p);-
493 Z = ((p->iJD + 129600000)/86400000) % 7;-
494 if( Z>n
Z>nDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test (438)
) Z -= 7;
executed 11 times by 1 test: Z -= 7;
Executed by:
  • Self test (438)
7-11
495 p->iJD += (n - Z)*86400000;-
496 clearYMD_HMS_TZ(p);-
497 rc = 0;-
498 }
executed 18 times by 1 test: end of block
Executed by:
  • Self test (438)
18
499 break;
executed 24 times by 1 test: break;
Executed by:
  • Self test (438)
24
500 }-
501 case
executed 29 times by 1 test: case 's':
Executed by:
  • Self test (438)
's':
executed 29 times by 1 test: case 's':
Executed by:
  • Self test (438)
{
29
502-
503-
504-
505-
506-
507-
508 if( sqlite3_strnicmp(z, "start of ", 9)!=0
sqlite3_strnic...rt of ", 9)!=0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
) break;
executed 1 time by 1 test: break;
Executed by:
  • Self test (438)
1-28
509 if( !p->validJD
!p->validJDDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test (438)
&& !p->validYMD
!p->validYMDDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
&& !p->validHMS
!p->validHMSDescription
TRUEnever evaluated
FALSEnever evaluated
) break;
never executed: break;
0-24
510 z += 9;-
511 computeYMD(p);-
512 p->validHMS = 1;-
513 p->h = p->m = 0;-
514 p->s = 0.0;-
515 p->rawS = 0;-
516 p->validTZ = 0;-
517 p->validJD = 0;-
518 if( sqlite3_stricmp(z,"month")==0
sqlite3_stricmp(z,"month")==0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
){
8-20
519 p->D = 1;-
520 rc = 0;-
521 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test (438)
else if( sqlite3_stricmp(z,"year")==0
sqlite3_stricmp(z,"year")==0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
){
8-10
522 p->M = 1;-
523 p->D = 1;-
524 rc = 0;-
525 }
executed 10 times by 1 test: end of block
Executed by:
  • Self test (438)
else if( sqlite3_stricmp(z,"day")==0
sqlite3_stricmp(z,"day")==0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
){
1-10
526 rc = 0;-
527 }
executed 9 times by 1 test: end of block
Executed by:
  • Self test (438)
9
528 break;
executed 28 times by 1 test: break;
Executed by:
  • Self test (438)
28
529 }-
530 case
executed 72 times by 1 test: case '+':
Executed by:
  • Self test (438)
'+':
executed 72 times by 1 test: case '+':
Executed by:
  • Self test (438)
72
531 case
executed 63 times by 1 test: case '-':
Executed by:
  • Self test (438)
'-':
executed 63 times by 1 test: case '-':
Executed by:
  • Self test (438)
63
532 case
executed 2 times by 1 test: case '0':
Executed by:
  • Self test (438)
'0':
executed 2 times by 1 test: case '0':
Executed by:
  • Self test (438)
2
533 case
executed 14 times by 1 test: case '1':
Executed by:
  • Self test (438)
'1':
executed 14 times by 1 test: case '1':
Executed by:
  • Self test (438)
14
534 case
executed 1 time by 1 test: case '2':
Executed by:
  • Self test (438)
'2':
executed 1 time by 1 test: case '2':
Executed by:
  • Self test (438)
1
535 case
executed 1 time by 1 test: case '3':
Executed by:
  • Self test (438)
'3':
executed 1 time by 1 test: case '3':
Executed by:
  • Self test (438)
1
536 case
executed 1 time by 1 test: case '4':
Executed by:
  • Self test (438)
'4':
executed 1 time by 1 test: case '4':
Executed by:
  • Self test (438)
1
537 case
executed 1 time by 1 test: case '5':
Executed by:
  • Self test (438)
'5':
executed 1 time by 1 test: case '5':
Executed by:
  • Self test (438)
1
538 case
executed 1 time by 1 test: case '6':
Executed by:
  • Self test (438)
'6':
executed 1 time by 1 test: case '6':
Executed by:
  • Self test (438)
1
539 case
executed 1 time by 1 test: case '7':
Executed by:
  • Self test (438)
'7':
executed 1 time by 1 test: case '7':
Executed by:
  • Self test (438)
1
540 case
executed 1 time by 1 test: case '8':
Executed by:
  • Self test (438)
'8':
executed 1 time by 1 test: case '8':
Executed by:
  • Self test (438)
1
541 case
executed 1 time by 1 test: case '9':
Executed by:
  • Self test (438)
'9':
executed 1 time by 1 test: case '9':
Executed by:
  • Self test (438)
{
1
542 double rRounder;-
543 int i;-
544 for(n=1; z[n]
z[n]Description
TRUEevaluated 628 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
&& z[n]!=':'
z[n]!=':'Description
TRUEevaluated 618 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
&& !(sqlite3CtypeMap[(unsigned char)(z[n])]&0x01)
!(sqlite3Ctype...)(z[n])]&0x01)Description
TRUEevaluated 470 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 148 times by 1 test
Evaluated by:
  • Self test (438)
; n++){}
executed 470 times by 1 test: end of block
Executed by:
  • Self test (438)
1-628
545 if( !sqlite3AtoF(z, &r, n, 1)
!sqlite3AtoF(z, &r, n, 1)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 158 times by 1 test
Evaluated by:
  • Self test (438)
){
1-158
546 rc = 1;-
547 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test (438)
1
548 }-
549 if( z[n]==':'
z[n]==':'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 148 times by 1 test
Evaluated by:
  • Self test (438)
){
10-148
550-
551-
552-
553-
554-
555 const char *z2 = z;-
556 DateTime tx;-
557 sqlite3_int64 day;-
558 if( !(sqlite3CtypeMap[(unsigned char)(*z2)]&0x04)
!(sqlite3Ctype...r)(*z2)]&0x04)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
) z2++;
executed 6 times by 1 test: z2++;
Executed by:
  • Self test (438)
4-6
559 memset(&tx, 0, sizeof(tx));-
560 if( parseHhMmSs(z2, &tx)
parseHhMmSs(z2, &tx)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
) break;
executed 1 time by 1 test: break;
Executed by:
  • Self test (438)
1-9
561 computeJD(&tx);-
562 tx.iJD -= 43200000;-
563 day = tx.iJD/86400000;-
564 tx.iJD -= day*86400000;-
565 if( z[0]=='-'
z[0]=='-'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
) tx.iJD = -tx.iJD;
executed 4 times by 1 test: tx.iJD = -tx.iJD;
Executed by:
  • Self test (438)
4-5
566 computeJD(p);-
567 clearYMD_HMS_TZ(p);-
568 p->iJD += tx.iJD;-
569 rc = 0;-
570 break;
executed 9 times by 1 test: break;
Executed by:
  • Self test (438)
9
571 }-
572-
573-
574-
575 z += n;-
576 while( (
(sqlite3CtypeM...ar)(*z)]&0x01)Description
TRUEevaluated 148 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 148 times by 1 test
Evaluated by:
  • Self test (438)
sqlite3CtypeMap[(unsigned char)(*z)]&0x01)
(sqlite3CtypeM...ar)(*z)]&0x01)Description
TRUEevaluated 148 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 148 times by 1 test
Evaluated by:
  • Self test (438)
) z++;
executed 148 times by 1 test: z++;
Executed by:
  • Self test (438)
148
577 n = sqlite3Strlen30(z);-
578 if( n>10
n>10Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 147 times by 1 test
Evaluated by:
  • Self test (438)
|| n<3
n<3Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 146 times by 1 test
Evaluated by:
  • Self test (438)
) break;
executed 2 times by 1 test: break;
Executed by:
  • Self test (438)
1-147
579 if( sqlite3UpperToLower[(u8)z[n-1]]=='s'
sqlite3UpperTo...8)z[n-1]]=='s'Description
TRUEevaluated 113 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test (438)
) n--;
executed 113 times by 1 test: n--;
Executed by:
  • Self test (438)
33-113
580 computeJD(p);-
581 rc = 1;-
582 rRounder = r<0
r<0Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 87 times by 1 test
Evaluated by:
  • Self test (438)
? -0.5 : +0.5;
59-87
583 for(i=0; i<((int)(sizeof(aXformType)/sizeof(aXformType[0])))
i<((int)(sizeo...formType[0])))Description
TRUEevaluated 561 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
; i++){
20-561
584 if( aXformType[i].nName==n
aXformType[i].nName==nDescription
TRUEevaluated 191 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 370 times by 1 test
Evaluated by:
  • Self test (438)
191-370
585 && sqlite3_strnicmp(aXformType[i].zName, z, n)==0
sqlite3_strnic...Name, z, n)==0Description
TRUEevaluated 138 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 53 times by 1 test
Evaluated by:
  • Self test (438)
53-138
586 && r>-aXformType[i].rLimit
r>-aXformType[i].rLimitDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
&& r<aXformType[i].rLimit
r<aXformType[i].rLimitDescription
TRUEevaluated 126 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
6-132
587 ){-
588 switch( aXformType[i].eType ){-
589 case
executed 22 times by 1 test: case 1:
Executed by:
  • Self test (438)
1:
executed 22 times by 1 test: case 1:
Executed by:
  • Self test (438)
{
22
590 int x;-
591 computeYMD_HMS(p);-
592 p->M += (int)r;-
593 x = p->M>0
p->M>0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
? (p->M-1)/12 : (p->M-12)/12;
9-13
594 p->Y += x;-
595 p->M -= x*12;-
596 p->validJD = 0;-
597 r -= (int)r;-
598 break;
executed 22 times by 1 test: break;
Executed by:
  • Self test (438)
22
599 }-
600 case
executed 21 times by 1 test: case 2:
Executed by:
  • Self test (438)
2:
executed 21 times by 1 test: case 2:
Executed by:
  • Self test (438)
{
21
601 int y = (int)r;-
602 computeYMD_HMS(p);-
603 p->Y += y;-
604 p->validJD = 0;-
605 r -= (int)r;-
606 break;
executed 21 times by 1 test: break;
Executed by:
  • Self test (438)
21
607 }-
608 }-
609 computeJD(p);-
610 p->iJD += (sqlite3_int64)(r*aXformType[i].rXform + rRounder);-
611 rc = 0;-
612 break;
executed 126 times by 1 test: break;
Executed by:
  • Self test (438)
126
613 }-
614 }
executed 435 times by 1 test: end of block
Executed by:
  • Self test (438)
435
615 clearYMD_HMS_TZ(p);-
616 break;
executed 146 times by 1 test: break;
Executed by:
  • Self test (438)
146
617 }-
618 default
executed 2 times by 1 test: default:
Executed by:
  • Self test (438)
:
executed 2 times by 1 test: default:
Executed by:
  • Self test (438)
{
2
619 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test (438)
2
620 }-
621 }-
622 return
executed 1246 times by 1 test: return rc;
Executed by:
  • Self test (438)
rc;
executed 1246 times by 1 test: return rc;
Executed by:
  • Self test (438)
1246
623}-
624static int isDate(-
625 sqlite3_context *context,-
626 int argc,-
627 sqlite3_value **argv,-
628 DateTime *p-
629){-
630 int i, n;-
631 const unsigned char *z;-
632 int eType;-
633 memset(p, 0, sizeof(*p));-
634 if( argc==0
argc==0Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4709 times by 1 test
Evaluated by:
  • Self test (438)
){
38-4709
635 return
executed 38 times by 1 test: return setDateTimeToCurrent(context, p);
Executed by:
  • Self test (438)
setDateTimeToCurrent(context, p);
executed 38 times by 1 test: return setDateTimeToCurrent(context, p);
Executed by:
  • Self test (438)
38
636 }-
637 if( (
(eType = sqlit...e(argv[0]))==2Description
TRUEevaluated 4369 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 340 times by 1 test
Evaluated by:
  • Self test (438)
eType = sqlite3_value_type(argv[0]))==2
(eType = sqlit...e(argv[0]))==2Description
TRUEevaluated 4369 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 340 times by 1 test
Evaluated by:
  • Self test (438)
340-4369
638 || eType==1
eType==1Description
TRUEevaluated 43 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 297 times by 1 test
Evaluated by:
  • Self test (438)
){
43-297
639 setRawDateNumber(p, sqlite3_value_double(argv[0]));-
640 }
executed 4412 times by 1 test: end of block
Executed by:
  • Self test (438)
else{
4412
641 z = sqlite3_value_text(argv[0]);-
642 if( !z
!zDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 292 times by 1 test
Evaluated by:
  • Self test (438)
|| parseDateOrTime(context, (char*)z, p)
parseDateOrTim..., (char*)z, p)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 266 times by 1 test
Evaluated by:
  • Self test (438)
){
5-292
643 return
executed 31 times by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 31 times by 1 test: return 1;
Executed by:
  • Self test (438)
31
644 }-
645 }
executed 266 times by 1 test: end of block
Executed by:
  • Self test (438)
266
646 for(i=1; i<argc
i<argcDescription
TRUEevaluated 1258 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4625 times by 1 test
Evaluated by:
  • Self test (438)
; i++){
1258-4625
647 z = sqlite3_value_text(argv[i]);-
648 n = sqlite3_value_bytes(argv[i]);-
649 if( z==0
z==0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1246 times by 1 test
Evaluated by:
  • Self test (438)
|| parseModifier(context, (char*)z, n, p)
parseModifier(...char*)z, n, p)Description
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1205 times by 1 test
Evaluated by:
  • Self test (438)
) return
executed 53 times by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 53 times by 1 test: return 1;
Executed by:
  • Self test (438)
12-1246
650 }
executed 1205 times by 1 test: end of block
Executed by:
  • Self test (438)
1205
651 computeJD(p);-
652 if( p->isError
p->isErrorDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4624 times by 1 test
Evaluated by:
  • Self test (438)
|| !validJulianDay(p->iJD)
!validJulianDay(p->iJD)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4623 times by 1 test
Evaluated by:
  • Self test (438)
) return
executed 2 times by 1 test: return 1;
Executed by:
  • Self test (438)
1;
executed 2 times by 1 test: return 1;
Executed by:
  • Self test (438)
1-4624
653 return
executed 4623 times by 1 test: return 0;
Executed by:
  • Self test (438)
0;
executed 4623 times by 1 test: return 0;
Executed by:
  • Self test (438)
4623
654}-
655static void juliandayFunc(-
656 sqlite3_context *context,-
657 int argc,-
658 sqlite3_value **argv-
659){-
660 DateTime x;-
661 if( isDate(context, argc, argv, &x)==0
isDate(context..., argv, &x)==0Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test (438)
){
18-52
662 computeJD(&x);-
663 sqlite3_result_double(context, x.iJD/86400000.0);-
664 }
executed 52 times by 1 test: end of block
Executed by:
  • Self test (438)
52
665}
executed 70 times by 1 test: end of block
Executed by:
  • Self test (438)
70
666-
667-
668-
669-
670-
671-
672static void datetimeFunc(-
673 sqlite3_context *context,-
674 int argc,-
675 sqlite3_value **argv-
676){-
677 DateTime x;-
678 if( isDate(context, argc, argv, &x)==0
isDate(context..., argv, &x)==0Description
TRUEevaluated 1953 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 47 times by 1 test
Evaluated by:
  • Self test (438)
){
47-1953
679 char zBuf[100];-
680 computeYMD_HMS(&x);-
681 sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d %02d:%02d:%02d",-
682 x.Y, x.M, x.D, x.h, x.m, (int)(x.s));-
683 sqlite3_result_text(context, zBuf, -1, ((sqlite3_destructor_type)-1));-
684 }
executed 1953 times by 1 test: end of block
Executed by:
  • Self test (438)
1953
685}
executed 2000 times by 1 test: end of block
Executed by:
  • Self test (438)
2000
686-
687-
688-
689-
690-
691-
692static void timeFunc(-
693 sqlite3_context *context,-
694 int argc,-
695 sqlite3_value **argv-
696){-
697 DateTime x;-
698 if( isDate(context, argc, argv, &x)==0
isDate(context..., argv, &x)==0Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
){
3-14
699 char zBuf[100];-
700 computeHMS(&x);-
701 sqlite3_snprintf(sizeof(zBuf), zBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s);-
702 sqlite3_result_text(context, zBuf, -1, ((sqlite3_destructor_type)-1));-
703 }
executed 14 times by 1 test: end of block
Executed by:
  • Self test (438)
14
704}
executed 17 times by 1 test: end of block
Executed by:
  • Self test (438)
17
705-
706-
707-
708-
709-
710-
711static void dateFunc(-
712 sqlite3_context *context,-
713 int argc,-
714 sqlite3_value **argv-
715){-
716 DateTime x;-
717 if( isDate(context, argc, argv, &x)==0
isDate(context..., argv, &x)==0Description
TRUEevaluated 1529 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test (438)
){
15-1529
718 char zBuf[100];-
719 computeYMD(&x);-
720 sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d", x.Y, x.M, x.D);-
721 sqlite3_result_text(context, zBuf, -1, ((sqlite3_destructor_type)-1));-
722 }
executed 1529 times by 1 test: end of block
Executed by:
  • Self test (438)
1529
723}
executed 1544 times by 1 test: end of block
Executed by:
  • Self test (438)
1544
724static void strftimeFunc(-
725 sqlite3_context *context,-
726 int argc,-
727 sqlite3_value **argv-
728){-
729 DateTime x;-
730 u64 n;-
731 size_t i,j;-
732 char *z;-
733 sqlite3 *db;-
734 const char *zFmt;-
735 char zBuf[100];-
736 if( argc==0
argc==0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1117 times by 1 test
Evaluated by:
  • Self test (438)
) return;
executed 2 times by 1 test: return;
Executed by:
  • Self test (438)
2-1117
737 zFmt = (const char*)sqlite3_value_text(argv[0]);-
738 if( zFmt==0
zFmt==0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1116 times by 1 test
Evaluated by:
  • Self test (438)
|| isDate(context, argc-1, argv+1, &x)
isDate(context...1, argv+1, &x)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1113 times by 1 test
Evaluated by:
  • Self test (438)
) return;
executed 4 times by 1 test: return;
Executed by:
  • Self test (438)
1-1116
739 db = sqlite3_context_db_handle(context);-
740 for(i=0, n=1; zFmt[i]
zFmt[i]Description
TRUEevaluated 6846 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1063 times by 1 test
Evaluated by:
  • Self test (438)
; i++, n++){
1063-6846
741 if( zFmt[i]=='%'
zFmt[i]=='%'Description
TRUEevaluated 3572 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3274 times by 1 test
Evaluated by:
  • Self test (438)
){
3274-3572
742 switch( zFmt[i+1] ){-
743 case
executed 11 times by 1 test: case 'd':
Executed by:
  • Self test (438)
'd':
executed 11 times by 1 test: case 'd':
Executed by:
  • Self test (438)
11
744 case
executed 1010 times by 1 test: case 'H':
Executed by:
  • Self test (438)
'H':
executed 1010 times by 1 test: case 'H':
Executed by:
  • Self test (438)
1010
745 case
executed 211 times by 1 test: case 'm':
Executed by:
  • Self test (438)
'm':
executed 211 times by 1 test: case 'm':
Executed by:
  • Self test (438)
211
746 case
executed 1010 times by 1 test: case 'M':
Executed by:
  • Self test (438)
'M':
executed 1010 times by 1 test: case 'M':
Executed by:
  • Self test (438)
1010
747 case
executed 5 times by 1 test: case 'S':
Executed by:
  • Self test (438)
'S':
executed 5 times by 1 test: case 'S':
Executed by:
  • Self test (438)
5
748 case
executed 27 times by 1 test: case 'W':
Executed by:
  • Self test (438)
'W':
executed 27 times by 1 test: case 'W':
Executed by:
  • Self test (438)
27
749 n++;-
750-
751 case
executed 1 time by 1 test: case 'w':
Executed by:
  • Self test (438)
'w':
executed 1 time by 1 test: case 'w':
Executed by:
  • Self test (438)
code before this statement executed 2274 times by 1 test: case 'w':
Executed by:
  • Self test (438)
1-2274
752 case
executed 1 time by 1 test: case '%':
Executed by:
  • Self test (438)
'%':
executed 1 time by 1 test: case '%':
Executed by:
  • Self test (438)
1
753 break;
executed 2276 times by 1 test: break;
Executed by:
  • Self test (438)
2276
754 case
executed 1007 times by 1 test: case 'f':
Executed by:
  • Self test (438)
'f':
executed 1007 times by 1 test: case 'f':
Executed by:
  • Self test (438)
1007
755 n += 8;-
756 break;
executed 1007 times by 1 test: break;
Executed by:
  • Self test (438)
1007
757 case
executed 14 times by 1 test: case 'j':
Executed by:
  • Self test (438)
'j':
executed 14 times by 1 test: case 'j':
Executed by:
  • Self test (438)
14
758 n += 3;-
759 break;
executed 14 times by 1 test: break;
Executed by:
  • Self test (438)
14
760 case
executed 211 times by 1 test: case 'Y':
Executed by:
  • Self test (438)
'Y':
executed 211 times by 1 test: case 'Y':
Executed by:
  • Self test (438)
211
761 n += 8;-
762 break;
executed 211 times by 1 test: break;
Executed by:
  • Self test (438)
211
763 case
executed 13 times by 1 test: case 's':
Executed by:
  • Self test (438)
's':
executed 13 times by 1 test: case 's':
Executed by:
  • Self test (438)
13
764 case
executed 1 time by 1 test: case 'J':
Executed by:
  • Self test (438)
'J':
executed 1 time by 1 test: case 'J':
Executed by:
  • Self test (438)
1
765 n += 50;-
766 break;
executed 14 times by 1 test: break;
Executed by:
  • Self test (438)
14
767 default
executed 50 times by 1 test: default:
Executed by:
  • Self test (438)
:
executed 50 times by 1 test: default:
Executed by:
  • Self test (438)
50
768 return;
executed 50 times by 1 test: return;
Executed by:
  • Self test (438)
50
769 }-
770 i++;-
771 }
executed 3522 times by 1 test: end of block
Executed by:
  • Self test (438)
3522
772 }
executed 6796 times by 1 test: end of block
Executed by:
  • Self test (438)
6796
773 ;-
774 ;-
775 ;-
776 ;-
777 if( n<sizeof(zBuf)
n<sizeof(zBuf)Description
TRUEevaluated 1061 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
){
2-1061
778 z = zBuf;-
779 }
executed 1061 times by 1 test: end of block
Executed by:
  • Self test (438)
else if( n>(u64)db->aLimit[0]
n>(u64)db->aLimit[0]Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
){
0-1061
780 sqlite3_result_error_toobig(context);-
781 return;
never executed: return;
0
782 }else{-
783 z = sqlite3DbMallocRawNN(db, (int)n);-
784 if( z==0
z==0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
){
0-2
785 sqlite3_result_error_nomem(context);-
786 return;
never executed: return;
0
787 }-
788 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test (438)
2
789 computeJD(&x);-
790 computeYMD_HMS(&x);-
791 for(i=j=0; zFmt[i]
zFmt[i]Description
TRUEevaluated 6796 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1063 times by 1 test
Evaluated by:
  • Self test (438)
; i++){
1063-6796
792 if( zFmt[i]!='%'
zFmt[i]!='%'Description
TRUEevaluated 3274 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3522 times by 1 test
Evaluated by:
  • Self test (438)
){
3274-3522
793 z[j++] = zFmt[i];-
794 }
executed 3274 times by 1 test: end of block
Executed by:
  • Self test (438)
else{
3274
795 i++;-
796 switch( zFmt[i] ){-
797 case
executed 11 times by 1 test: case 'd':
Executed by:
  • Self test (438)
'd':
executed 11 times by 1 test: case 'd':
Executed by:
  • Self test (438)
sqlite3_snprintf(3, &z[j],"%02d",x.D); j+=2; break;
executed 11 times by 1 test: break;
Executed by:
  • Self test (438)
11
798 case
executed 1007 times by 1 test: case 'f':
Executed by:
  • Self test (438)
'f':
executed 1007 times by 1 test: case 'f':
Executed by:
  • Self test (438)
{
1007
799 double s = x.s;-
800 if( s>59.999
s>59.999Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1006 times by 1 test
Evaluated by:
  • Self test (438)
) s = 59.999;
executed 1 time by 1 test: s = 59.999;
Executed by:
  • Self test (438)
1-1006
801 sqlite3_snprintf(7, &z[j],"%06.3f", s);-
802 j += sqlite3Strlen30(&z[j]);-
803 break;
executed 1007 times by 1 test: break;
Executed by:
  • Self test (438)
1007
804 }-
805 case
executed 1010 times by 1 test: case 'H':
Executed by:
  • Self test (438)
'H':
executed 1010 times by 1 test: case 'H':
Executed by:
  • Self test (438)
sqlite3_snprintf(3, &z[j],"%02d",x.h); j+=2; break;
executed 1010 times by 1 test: break;
Executed by:
  • Self test (438)
1010
806 case
executed 27 times by 1 test: case 'W':
Executed by:
  • Self test (438)
'W':
executed 27 times by 1 test: case 'W':
Executed by:
  • Self test (438)
27
807 case
executed 14 times by 1 test: case 'j':
Executed by:
  • Self test (438)
'j':
executed 14 times by 1 test: case 'j':
Executed by:
  • Self test (438)
{
14
808 int nDay;-
809 DateTime y = x;-
810 y.validJD = 0;-
811 y.M = 1;-
812 y.D = 1;-
813 computeJD(&y);-
814 nDay = (int)((x.iJD-y.iJD+43200000)/86400000);-
815 if( zFmt[i]=='W'
zFmt[i]=='W'Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
){
14-27
816 int wd;-
817 wd = (int)(((x.iJD+43200000)/86400000)%7);-
818 sqlite3_snprintf(3, &z[j],"%02d",(nDay+7-wd)/7);-
819 j += 2;-
820 }
executed 27 times by 1 test: end of block
Executed by:
  • Self test (438)
else{
27
821 sqlite3_snprintf(4, &z[j],"%03d",nDay+1);-
822 j += 3;-
823 }
executed 14 times by 1 test: end of block
Executed by:
  • Self test (438)
14
824 break;
executed 41 times by 1 test: break;
Executed by:
  • Self test (438)
41
825 }-
826 case
executed 1 time by 1 test: case 'J':
Executed by:
  • Self test (438)
'J':
executed 1 time by 1 test: case 'J':
Executed by:
  • Self test (438)
{
1
827 sqlite3_snprintf(20, &z[j],"%.16g",x.iJD/86400000.0);-
828 j+=sqlite3Strlen30(&z[j]);-
829 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test (438)
1
830 }-
831 case
executed 211 times by 1 test: case 'm':
Executed by:
  • Self test (438)
'm':
executed 211 times by 1 test: case 'm':
Executed by:
  • Self test (438)
sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
executed 211 times by 1 test: break;
Executed by:
  • Self test (438)
211
832 case
executed 1010 times by 1 test: case 'M':
Executed by:
  • Self test (438)
'M':
executed 1010 times by 1 test: case 'M':
Executed by:
  • Self test (438)
sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break;
executed 1010 times by 1 test: break;
Executed by:
  • Self test (438)
1010
833 case
executed 13 times by 1 test: case 's':
Executed by:
  • Self test (438)
's':
executed 13 times by 1 test: case 's':
Executed by:
  • Self test (438)
{
13
834 sqlite3_snprintf(30,&z[j],"%lld",-
835 (i64)(x.iJD/1000 - 21086676*(i64)10000));-
836 j += sqlite3Strlen30(&z[j]);-
837 break;
executed 13 times by 1 test: break;
Executed by:
  • Self test (438)
13
838 }-
839 case
executed 5 times by 1 test: case 'S':
Executed by:
  • Self test (438)
'S':
executed 5 times by 1 test: case 'S':
Executed by:
  • Self test (438)
sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break;
executed 5 times by 1 test: break;
Executed by:
  • Self test (438)
5
840 case
executed 1 time by 1 test: case 'w':
Executed by:
  • Self test (438)
'w':
executed 1 time by 1 test: case 'w':
Executed by:
  • Self test (438)
{
1
841 z[j++] = (char)(((x.iJD+129600000)/86400000) % 7) + '0';-
842 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test (438)
1
843 }-
844 case
executed 211 times by 1 test: case 'Y':
Executed by:
  • Self test (438)
'Y':
executed 211 times by 1 test: case 'Y':
Executed by:
  • Self test (438)
{
211
845 sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=sqlite3Strlen30(&z[j]);-
846 break;
executed 211 times by 1 test: break;
Executed by:
  • Self test (438)
211
847 }-
848 default
executed 1 time by 1 test: default:
Executed by:
  • Self test (438)
:
executed 1 time by 1 test: default:
Executed by:
  • Self test (438)
z[j++] = '%'; break;
executed 1 time by 1 test: break;
Executed by:
  • Self test (438)
1
849 }-
850 }-
851 }-
852 z[j] = 0;-
853 sqlite3_result_text(context, z, -1,-
854 z==zBuf ? ((sqlite3_destructor_type)-1) : ((sqlite3_destructor_type)sqlite3MallocSize));-
855}
executed 1063 times by 1 test: end of block
Executed by:
  • Self test (438)
1063
856-
857-
858-
859-
860-
861-
862static void ctimeFunc(-
863 sqlite3_context *context,-
864 int NotUsed,-
865 sqlite3_value **NotUsed2-
866){-
867 (void)(NotUsed),(void)(NotUsed2);-
868 timeFunc(context, 0, 0);-
869}
executed 12 times by 1 test: end of block
Executed by:
  • Self test (438)
12
870-
871-
872-
873-
874-
875-
876static void cdateFunc(-
877 sqlite3_context *context,-
878 int NotUsed,-
879 sqlite3_value **NotUsed2-
880){-
881 (void)(NotUsed),(void)(NotUsed2);-
882 dateFunc(context, 0, 0);-
883}
executed 12 times by 1 test: end of block
Executed by:
  • Self test (438)
12
884-
885-
886-
887-
888-
889-
890static void ctimestampFunc(-
891 sqlite3_context *context,-
892 int NotUsed,-
893 sqlite3_value **NotUsed2-
894){-
895 (void)(NotUsed),(void)(NotUsed2);-
896 datetimeFunc(context, 0, 0);-
897}
executed 13 times by 1 test: end of block
Executed by:
  • Self test (438)
13
898void sqlite3RegisterDateTimeFunctions(void){-
899 static FuncDef aDateTimeFuncs[] = {-
900-
901 {-1, 0x2000|1|0x0800, (void*)&sqlite3Config, 0, juliandayFunc, 0, 0, 0, "julianday", {0} },-
902 {-1, 0x2000|1|0x0800, (void*)&sqlite3Config, 0, dateFunc, 0, 0, 0, "date", {0} },-
903 {-1, 0x2000|1|0x0800, (void*)&sqlite3Config, 0, timeFunc, 0, 0, 0, "time", {0} },-
904 {-1, 0x2000|1|0x0800, (void*)&sqlite3Config, 0, datetimeFunc, 0, 0, 0, "datetime", {0} },-
905 {-1, 0x2000|1|0x0800, (void*)&sqlite3Config, 0, strftimeFunc, 0, 0, 0, "strftime", {0} },-
906 {0, 0x2000|1, 0, 0, ctimeFunc, 0, 0, 0, "current_time", {0} },-
907 {0, 0x2000|1, 0, 0, ctimestampFunc, 0, 0, 0, "current_timestamp", {0} },-
908 {0, 0x2000|1, 0, 0, cdateFunc, 0, 0, 0, "current_date", {0} },-
909-
910-
911-
912-
913-
914 };-
915 sqlite3InsertBuiltinFuncs(aDateTimeFuncs, ((int)(sizeof(aDateTimeFuncs)/sizeof(aDateTimeFuncs[0]))));-
916}
executed 534 times by 438 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • ...
534
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2