Lines Matching refs:p
148 static int parseTimezone(const char *zDate, DateTime *p){ in parseTimezone() argument
152 p->tz = 0; in parseTimezone()
165 p->tz = sgn*(nMn + nHr*60); in parseTimezone()
177 static int parseHhMmSs(const char *zDate, DateTime *p){ in parseHhMmSs() argument
203 p->validJD = 0; in parseHhMmSs()
204 p->validHMS = 1; in parseHhMmSs()
205 p->h = h; in parseHhMmSs()
206 p->m = m; in parseHhMmSs()
207 p->s = s + ms; in parseHhMmSs()
208 if( parseTimezone(zDate, p) ) return 1; in parseHhMmSs()
209 p->validTZ = p->tz!=0; in parseHhMmSs()
219 static void computeJD(DateTime *p){ in computeJD() argument
222 if( p->validJD ) return; in computeJD()
223 if( p->validYMD ){ in computeJD()
224 Y = p->Y; in computeJD()
225 M = p->M; in computeJD()
226 D = p->D; in computeJD()
240 p->rJD = X1 + X2 + D + B - 1524.5; in computeJD()
241 p->validJD = 1; in computeJD()
242 p->validYMD = 0; in computeJD()
243 if( p->validHMS ){ in computeJD()
244 p->rJD += (p->h*3600.0 + p->m*60.0 + p->s)/86400.0; in computeJD()
245 if( p->validTZ ){ in computeJD()
246 p->rJD += p->tz*60/86400.0; in computeJD()
247 p->validHMS = 0; in computeJD()
248 p->validTZ = 0; in computeJD()
265 static int parseYyyyMmDd(const char *zDate, DateTime *p){ in parseYyyyMmDd() argument
279 if( parseHhMmSs(zDate, p)==0 ){ in parseYyyyMmDd()
282 p->validHMS = 0; in parseYyyyMmDd()
286 p->validJD = 0; in parseYyyyMmDd()
287 p->validYMD = 1; in parseYyyyMmDd()
288 p->Y = neg ? -Y : Y; in parseYyyyMmDd()
289 p->M = M; in parseYyyyMmDd()
290 p->D = D; in parseYyyyMmDd()
291 if( p->validTZ ){ in parseYyyyMmDd()
292 computeJD(p); in parseYyyyMmDd()
313 static int parseDateOrTime(const char *zDate, DateTime *p){ in parseDateOrTime() argument
314 memset(p, 0, sizeof(*p)); in parseDateOrTime()
315 if( parseYyyyMmDd(zDate,p)==0 ){ in parseDateOrTime()
317 }else if( parseHhMmSs(zDate, p)==0 ){ in parseDateOrTime()
322 p->rJD = r; in parseDateOrTime()
323 p->validJD = 1; in parseDateOrTime()
328 p->rJD = sqliteAtoF(zDate, 0); in parseDateOrTime()
329 p->validJD = 1; in parseDateOrTime()
338 static void computeYMD(DateTime *p){ in computeYMD() argument
340 if( p->validYMD ) return; in computeYMD()
341 if( !p->validJD ){ in computeYMD()
342 p->Y = 2000; in computeYMD()
343 p->M = 1; in computeYMD()
344 p->D = 1; in computeYMD()
346 Z = p->rJD + 0.5; in computeYMD()
354 p->D = B - D - X1; in computeYMD()
355 p->M = E<14 ? E-1 : E-13; in computeYMD()
356 p->Y = p->M>2 ? C - 4716 : C - 4715; in computeYMD()
358 p->validYMD = 1; in computeYMD()
364 static void computeHMS(DateTime *p){ in computeHMS() argument
366 if( p->validHMS ) return; in computeHMS()
367 Z = p->rJD + 0.5; in computeHMS()
368 s = (p->rJD + 0.5 - Z)*86400000.0 + 0.5; in computeHMS()
369 p->s = 0.001*s; in computeHMS()
370 s = p->s; in computeHMS()
371 p->s -= s; in computeHMS()
372 p->h = s/3600; in computeHMS()
373 s -= p->h*3600; in computeHMS()
374 p->m = s/60; in computeHMS()
375 p->s += s - p->m*60; in computeHMS()
376 p->validHMS = 1; in computeHMS()
382 static void computeYMD_HMS(DateTime *p){ in computeYMD_HMS() argument
383 computeYMD(p); in computeYMD_HMS()
384 computeHMS(p); in computeYMD_HMS()
390 static void clearYMD_HMS_TZ(DateTime *p){ in clearYMD_HMS_TZ() argument
391 p->validYMD = 0; in clearYMD_HMS_TZ()
392 p->validHMS = 0; in clearYMD_HMS_TZ()
393 p->validTZ = 0; in clearYMD_HMS_TZ()
400 static double localtimeOffset(DateTime *p){ in localtimeOffset() argument
404 x = *p; in localtimeOffset()
462 static int parseModifier(const char *zMod, DateTime *p){ in parseModifier() argument
480 computeJD(p); in parseModifier()
481 p->rJD += localtimeOffset(p); in parseModifier()
482 clearYMD_HMS_TZ(p); in parseModifier()
494 if( strcmp(z, "unixepoch")==0 && p->validJD ){ in parseModifier()
495 p->rJD = p->rJD/86400.0 + 2440587.5; in parseModifier()
496 clearYMD_HMS_TZ(p); in parseModifier()
500 computeJD(p); in parseModifier()
501 c1 = localtimeOffset(p); in parseModifier()
502 p->rJD -= c1; in parseModifier()
503 clearYMD_HMS_TZ(p); in parseModifier()
504 p->rJD += c1 - localtimeOffset(p); in parseModifier()
520 computeYMD_HMS(p); in parseModifier()
521 p->validTZ = 0; in parseModifier()
522 p->validJD = 0; in parseModifier()
523 computeJD(p); in parseModifier()
524 Z = p->rJD + 1.5; in parseModifier()
527 p->rJD += n - Z; in parseModifier()
528 clearYMD_HMS_TZ(p); in parseModifier()
542 computeYMD(p); in parseModifier()
543 p->validHMS = 1; in parseModifier()
544 p->h = p->m = 0; in parseModifier()
545 p->s = 0.0; in parseModifier()
546 p->validTZ = 0; in parseModifier()
547 p->validJD = 0; in parseModifier()
549 p->D = 1; in parseModifier()
552 computeYMD(p); in parseModifier()
553 p->M = 1; in parseModifier()
554 p->D = 1; in parseModifier()
592 computeJD(p); in parseModifier()
593 clearYMD_HMS_TZ(p); in parseModifier()
594 p->rJD += tx.rJD; in parseModifier()
603 computeJD(p); in parseModifier()
606 p->rJD += r; in parseModifier()
608 p->rJD += r/24.0; in parseModifier()
610 p->rJD += r/(24.0*60.0); in parseModifier()
612 p->rJD += r/(24.0*60.0*60.0); in parseModifier()
615 computeYMD_HMS(p); in parseModifier()
616 p->M += r; in parseModifier()
617 x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12; in parseModifier()
618 p->Y += x; in parseModifier()
619 p->M -= x*12; in parseModifier()
620 p->validJD = 0; in parseModifier()
621 computeJD(p); in parseModifier()
624 p->rJD += (r - y)*30.0; in parseModifier()
627 computeYMD_HMS(p); in parseModifier()
628 p->Y += r; in parseModifier()
629 p->validJD = 0; in parseModifier()
630 computeJD(p); in parseModifier()
634 clearYMD_HMS_TZ(p); in parseModifier()
650 static int isDate(int argc, const char **argv, DateTime *p){ in isDate() argument
653 if( argv[0]==0 || parseDateOrTime(argv[0], p) ) return 1; in isDate()
655 if( argv[i]==0 || parseModifier(argv[i], p) ) return 1; in isDate()