mirror of
https://github.com/php/php-src.git
synced 2024-12-01 13:54:10 +08:00
Upgrade timelib to 2017.05beta7
This commit is contained in:
parent
3af6201224
commit
bdd56f3107
@ -1,6 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Derick Rethans
|
||||
Copyright (c) 2015-2017 Derick Rethans
|
||||
Copyright (c) 2017 MongoDB, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -26,15 +26,15 @@
|
||||
| Schlyter, who wrote this in December 1992 |
|
||||
*/
|
||||
|
||||
#include "timelib.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "timelib.h"
|
||||
|
||||
#define days_since_2000_Jan_0(y,m,d) \
|
||||
(367L*(y)-((7*((y)+(((m)+9)/12)))/4)+((275*(m))/9)+(d)-730530L)
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.1415926535897932384
|
||||
# define PI 3.1415926535897932384
|
||||
#endif
|
||||
|
||||
#define RADEG ( 180.0 / PI )
|
||||
@ -230,7 +230,8 @@ int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat,
|
||||
t_loc->i = t_loc->s = 0;
|
||||
timelib_update_ts(t_loc, NULL);
|
||||
|
||||
/* Calculate TS belonging to UTC 00:00 of the current day */
|
||||
/* Calculate TS belonging to UTC 00:00 of the current day, for input into
|
||||
* the algorithm */
|
||||
t_utc = timelib_time_ctor();
|
||||
t_utc->y = t_loc->y;
|
||||
t_utc->m = t_loc->m;
|
||||
@ -239,8 +240,8 @@ int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat,
|
||||
timelib_update_ts(t_utc, NULL);
|
||||
|
||||
/* Compute d of 12h local mean solar time */
|
||||
timestamp = t_loc->sse;
|
||||
d = timelib_ts_to_juliandate(timestamp) - lon/360.0;
|
||||
timestamp = t_utc->sse;
|
||||
d = timelib_ts_to_j2000(timestamp) + 2 - lon/360.0;
|
||||
|
||||
/* Compute local sidereal time of this moment */
|
||||
sidtime = astro_revolution(astro_GMST0(d) + 180.0 + lon);
|
||||
@ -295,14 +296,18 @@ int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat,
|
||||
return rc;
|
||||
}
|
||||
|
||||
double timelib_ts_to_juliandate(timelib_sll ts)
|
||||
double timelib_ts_to_julianday(timelib_sll ts)
|
||||
{
|
||||
double tmp;
|
||||
|
||||
tmp = ts;
|
||||
tmp /= 86400;
|
||||
tmp += 2440587.5;
|
||||
tmp -= 2451543;
|
||||
tmp = (double) ts;
|
||||
tmp /= (double) 86400;
|
||||
tmp += (double) 2440587.5;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
double timelib_ts_to_j2000(timelib_sll ts)
|
||||
{
|
||||
return timelib_ts_to_julianday(ts) - 2451545;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "timelib.h"
|
||||
#include "timelib_private.h"
|
||||
|
||||
static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
|
||||
static int m_table_leap[13] = { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
|
||||
@ -137,17 +138,71 @@ void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, time
|
||||
}
|
||||
}
|
||||
|
||||
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d)
|
||||
void timelib_isodate_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iy, timelib_sll *iw, timelib_sll *id)
|
||||
{
|
||||
timelib_isoweek_from_date(y, m, d, iw, iy);
|
||||
*id = timelib_day_of_week_ex(y, m, d, 1);
|
||||
}
|
||||
|
||||
static timelib_sll timelib_daynr_from_weeknr_ex(timelib_sll iy, timelib_sll iw, timelib_sll id, timelib_sll *y)
|
||||
{
|
||||
timelib_sll dow, day;
|
||||
|
||||
/* Figure out the dayofweek for y-1-1 */
|
||||
dow = timelib_day_of_week(y, 1, 1);
|
||||
dow = timelib_day_of_week(iy, 1, 1);
|
||||
/* then use that to figure out the offset for day 1 of week 1 */
|
||||
day = 0 - (dow > 4 ? dow - 7 : dow);
|
||||
/* and adjust the year to the natural year if we need to */
|
||||
*y = (iw == 1 && day < 0 && id < dow) ? iy - 1 : iy;
|
||||
|
||||
/* Add weeks and days */
|
||||
return day + ((w - 1) * 7) + d;
|
||||
return day + ((iw - 1) * 7) + id;
|
||||
}
|
||||
|
||||
timelib_sll timelib_daynr_from_weeknr(timelib_sll iy, timelib_sll iw, timelib_sll id)
|
||||
{
|
||||
timelib_sll dummy_iso_year;
|
||||
|
||||
return timelib_daynr_from_weeknr_ex(iy, iw, id, &dummy_iso_year);
|
||||
}
|
||||
|
||||
void timelib_date_from_isodate(timelib_sll iy, timelib_sll iw, timelib_sll id, timelib_sll *y, timelib_sll *m, timelib_sll *d)
|
||||
{
|
||||
timelib_sll daynr = timelib_daynr_from_weeknr_ex(iy, iw, id, y) + 1;
|
||||
int *table;
|
||||
|
||||
*m = 0;
|
||||
|
||||
if (daynr <= 0) {
|
||||
*y += 1;
|
||||
}
|
||||
|
||||
if (timelib_is_leap(*y)) {
|
||||
table = ml_table_leap;
|
||||
if (daynr > 366) {
|
||||
*y += 1;
|
||||
daynr -= 366;
|
||||
}
|
||||
} else {
|
||||
table = ml_table_common;
|
||||
if (daynr > 365) {
|
||||
*y += 1;
|
||||
daynr -= 365;
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
daynr -= table[*m];
|
||||
(*m)++;
|
||||
} while (daynr > table[*m]);
|
||||
|
||||
if (daynr <= 0) {
|
||||
daynr += 31;
|
||||
*y -= 1;
|
||||
*m = 12;
|
||||
}
|
||||
|
||||
*d = daynr;
|
||||
}
|
||||
|
||||
int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s)
|
||||
|
@ -1,42 +1,42 @@
|
||||
{ "sst", 0, -660, "Pacific/Apia" },
|
||||
{ "hst", 0, -600, "Pacific/Honolulu" },
|
||||
{ "akst", 0, -540, "America/Anchorage" },
|
||||
{ "akdt", 1, -480, "America/Anchorage" },
|
||||
{ "pst", 0, -480, "America/Los_Angeles" },
|
||||
{ "pdt", 1, -420, "America/Los_Angeles" },
|
||||
{ "mst", 0, -420, "America/Denver" },
|
||||
{ "mdt", 1, -360, "America/Denver" },
|
||||
{ "cst", 0, -360, "America/Chicago" },
|
||||
{ "cdt", 1, -300, "America/Chicago" },
|
||||
{ "est", 0, -300, "America/New_York" },
|
||||
{ "vet", 0, -270, "America/Caracas" },
|
||||
{ "edt", 1, -240, "America/New_York" },
|
||||
{ "ast", 0, -240, "America/Halifax" },
|
||||
{ "adt", 1, -180, "America/Halifax" },
|
||||
{ "brt", 0, -180, "America/Sao_Paulo" },
|
||||
{ "brst", 1, -120, "America/Sao_Paulo" },
|
||||
{ "azost", 0, -60, "Atlantic/Azores" },
|
||||
{ "azodt", 1, 0, "Atlantic/Azores" },
|
||||
{ "gmt", 0, 0, "Europe/London" },
|
||||
{ "bst", 1, 60, "Europe/London" },
|
||||
{ "cet", 0, 60, "Europe/Paris" },
|
||||
{ "cest", 1, 120, "Europe/Paris" },
|
||||
{ "eet", 0, 120, "Europe/Helsinki" },
|
||||
{ "eest", 1, 180, "Europe/Helsinki" },
|
||||
{ "msk", 0, 180, "Europe/Moscow" },
|
||||
{ "msd", 1, 240, "Europe/Moscow" },
|
||||
{ "gst", 0, 240, "Asia/Dubai" },
|
||||
{ "pkt", 0, 300, "Asia/Karachi" },
|
||||
{ "ist", 0, 330, "Asia/Kolkata" },
|
||||
{ "npt", 0, 345, "Asia/Katmandu" },
|
||||
{ "yekt", 1, 360, "Asia/Yekaterinburg" },
|
||||
{ "novst", 1, 420, "Asia/Novosibirsk" },
|
||||
{ "krat", 0, 420, "Asia/Krasnoyarsk" },
|
||||
{ "cst", 0, 480, "Asia/Shanghai" },
|
||||
{ "krast", 1, 480, "Asia/Krasnoyarsk" },
|
||||
{ "jst", 0, 540, "Asia/Tokyo" },
|
||||
{ "est", 0, 600, "Australia/Melbourne" },
|
||||
{ "cst", 1, 630, "Australia/Adelaide" },
|
||||
{ "est", 1, 660, "Australia/Melbourne" },
|
||||
{ "nzst", 0, 720, "Pacific/Auckland" },
|
||||
{ "nzdt", 1, 780, "Pacific/Auckland" },
|
||||
{ "sst", 0, -660 * 60, "Pacific/Apia" },
|
||||
{ "hst", 0, -600 * 60, "Pacific/Honolulu" },
|
||||
{ "akst", 0, -540 * 60, "America/Anchorage" },
|
||||
{ "akdt", 1, -480 * 60, "America/Anchorage" },
|
||||
{ "pst", 0, -480 * 60, "America/Los_Angeles" },
|
||||
{ "pdt", 1, -420 * 60, "America/Los_Angeles" },
|
||||
{ "mst", 0, -420 * 60, "America/Denver" },
|
||||
{ "mdt", 1, -360 * 60, "America/Denver" },
|
||||
{ "cst", 0, -360 * 60, "America/Chicago" },
|
||||
{ "cdt", 1, -300 * 60, "America/Chicago" },
|
||||
{ "est", 0, -300 * 60, "America/New_York" },
|
||||
{ "vet", 0, -270 * 60, "America/Caracas" },
|
||||
{ "edt", 1, -240 * 60, "America/New_York" },
|
||||
{ "ast", 0, -240 * 60, "America/Halifax" },
|
||||
{ "adt", 1, -180 * 60, "America/Halifax" },
|
||||
{ "brt", 0, -180 * 60, "America/Sao_Paulo" },
|
||||
{ "brst", 1, -120 * 60, "America/Sao_Paulo" },
|
||||
{ "azost", 0, -60 * 60, "Atlantic/Azores" },
|
||||
{ "azodt", 1, 0 * 60, "Atlantic/Azores" },
|
||||
{ "gmt", 0, 0 * 60, "Europe/London" },
|
||||
{ "bst", 1, 60 * 60, "Europe/London" },
|
||||
{ "cet", 0, 60 * 60, "Europe/Paris" },
|
||||
{ "cest", 1, 120 * 60, "Europe/Paris" },
|
||||
{ "eet", 0, 120 * 60, "Europe/Helsinki" },
|
||||
{ "eest", 1, 180 * 60, "Europe/Helsinki" },
|
||||
{ "msk", 0, 180 * 60, "Europe/Moscow" },
|
||||
{ "msd", 1, 240 * 60, "Europe/Moscow" },
|
||||
{ "gst", 0, 240 * 60, "Asia/Dubai" },
|
||||
{ "pkt", 0, 300 * 60, "Asia/Karachi" },
|
||||
{ "ist", 0, 330 * 60, "Asia/Kolkata" },
|
||||
{ "npt", 0, 345 * 60, "Asia/Katmandu" },
|
||||
{ "yekt", 1, 360 * 60, "Asia/Yekaterinburg" },
|
||||
{ "novst", 1, 420 * 60, "Asia/Novosibirsk" },
|
||||
{ "krat", 0, 420 * 60, "Asia/Krasnoyarsk" },
|
||||
{ "cst", 0, 480 * 60, "Asia/Shanghai" },
|
||||
{ "krast", 1, 480 * 60, "Asia/Krasnoyarsk" },
|
||||
{ "jst", 0, 540 * 60, "Asia/Tokyo" },
|
||||
{ "est", 0, 600 * 60, "Australia/Melbourne" },
|
||||
{ "cst", 1, 630 * 60, "Australia/Adelaide" },
|
||||
{ "est", 1, 660 * 60, "Australia/Melbourne" },
|
||||
{ "nzst", 0, 720 * 60, "Pacific/Auckland" },
|
||||
{ "nzdt", 1, 780 * 60, "Pacific/Auckland" },
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "timelib.h"
|
||||
#include "timelib_private.h"
|
||||
#include <math.h>
|
||||
|
||||
timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
|
||||
@ -65,6 +66,7 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
|
||||
rt->h = two->h - one->h;
|
||||
rt->i = two->i - one->i;
|
||||
rt->s = two->s - one->s;
|
||||
rt->us = two->us - one->us;
|
||||
if (one_backup.dst == 0 && two_backup.dst == 1 && two->sse >= one->sse + 86400 - dst_corr) {
|
||||
rt->h += dst_h_corr;
|
||||
rt->i += dst_m_corr;
|
||||
@ -110,6 +112,7 @@ timelib_time *timelib_add(timelib_time *old_time, timelib_rel_time *interval)
|
||||
t->relative.h = interval->h * bias;
|
||||
t->relative.i = interval->i * bias;
|
||||
t->relative.s = interval->s * bias;
|
||||
t->relative.us = interval->us * bias;
|
||||
}
|
||||
t->have_relative = 1;
|
||||
t->sse_uptodate = 0;
|
||||
@ -145,6 +148,7 @@ timelib_time *timelib_sub(timelib_time *old_time, timelib_rel_time *interval)
|
||||
t->relative.h = 0 - (interval->h * bias);
|
||||
t->relative.i = 0 - (interval->i * bias);
|
||||
t->relative.s = 0 - (interval->s * bias);
|
||||
t->relative.us = 0 - (interval->us * bias);
|
||||
t->have_relative = 1;
|
||||
t->sse_uptodate = 0;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
23670
ext/date/lib/parse_date.c.orig
Normal file
23670
ext/date/lib/parse_date.c.orig
Normal file
File diff suppressed because it is too large
Load Diff
@ -25,21 +25,12 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "timelib.h"
|
||||
#include "timelib_private.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define strtoll(s, f, b) _atoi64(s)
|
||||
#elif !defined(HAVE_STRTOLL)
|
||||
@ -50,17 +41,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define TIMELIB_UNSET -99999
|
||||
|
||||
#define TIMELIB_SECOND 1
|
||||
#define TIMELIB_MINUTE 2
|
||||
#define TIMELIB_HOUR 3
|
||||
#define TIMELIB_DAY 4
|
||||
#define TIMELIB_MONTH 5
|
||||
#define TIMELIB_YEAR 6
|
||||
#define TIMELIB_WEEKDAY 7
|
||||
#define TIMELIB_SPECIAL 8
|
||||
|
||||
#define EOI 257
|
||||
#define TIME 258
|
||||
#define DATE 259
|
||||
@ -112,14 +92,14 @@ typedef unsigned char uchar;
|
||||
|
||||
#define timelib_string_free timelib_free
|
||||
|
||||
#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { add_error(s, "Double time specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
|
||||
#define TIMELIB_UNHAVE_TIME() { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; }
|
||||
#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { add_error(s, "Double date specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_date = 1; } }
|
||||
#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { add_error(s, TIMELIB_ERR_DOUBLE_TIME, "Double time specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->us = 0; } }
|
||||
#define TIMELIB_UNHAVE_TIME() { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->us = 0; }
|
||||
#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { add_error(s, TIMELIB_ERR_DOUBLE_DATE, "Double date specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_date = 1; } }
|
||||
#define TIMELIB_UNHAVE_DATE() { s->time->have_date = 0; s->time->d = 0; s->time->m = 0; s->time->y = 0; }
|
||||
#define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; }
|
||||
#define TIMELIB_HAVE_WEEKDAY_RELATIVE() { s->time->have_relative = 1; s->time->relative.have_weekday_relative = 1; }
|
||||
#define TIMELIB_HAVE_SPECIAL_RELATIVE() { s->time->have_relative = 1; s->time->relative.have_special_relative = 1; }
|
||||
#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { s->time->have_zone > 1 ? add_error(s, "Double timezone specification") : add_warning(s, "Double timezone specification"); timelib_string_free(str); s->time->have_zone++; return TIMELIB_ERROR; } else { s->time->have_zone++; } }
|
||||
#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { s->time->have_zone > 1 ? add_error(s, TIMELIB_ERR_DOUBLE_TZ, "Double timezone specification") : add_warning(s, TIMELIB_WARN_DOUBLE_TZ, "Double timezone specification"); timelib_string_free(str); s->time->have_zone++; return TIMELIB_ERROR; } else { s->time->have_zone++; } }
|
||||
|
||||
#define TIMELIB_INIT s->cur = cursor; str = timelib_string(s); ptr = str
|
||||
#define TIMELIB_DEINIT timelib_string_free(str)
|
||||
@ -145,8 +125,6 @@ typedef unsigned char uchar;
|
||||
#define YYDEBUG(s,c)
|
||||
#endif
|
||||
|
||||
#include "timelib_structs.h"
|
||||
|
||||
typedef struct timelib_elems {
|
||||
unsigned int c; /* Number of elements */
|
||||
char **v; /* Values */
|
||||
@ -175,21 +153,33 @@ typedef struct _timelib_relunit {
|
||||
} timelib_relunit;
|
||||
|
||||
/* The timezone table. */
|
||||
const static timelib_tz_lookup_table timelib_timezone_lookup[] = {
|
||||
static const timelib_tz_lookup_table timelib_timezone_lookup[] = {
|
||||
#include "timezonemap.h"
|
||||
{ NULL, 0, 0, NULL },
|
||||
};
|
||||
|
||||
const static timelib_tz_lookup_table timelib_timezone_fallbackmap[] = {
|
||||
static const timelib_tz_lookup_table timelib_timezone_fallbackmap[] = {
|
||||
#include "fallbackmap.h"
|
||||
{ NULL, 0, 0, NULL },
|
||||
};
|
||||
|
||||
const static timelib_tz_lookup_table timelib_timezone_utc[] = {
|
||||
static const timelib_tz_lookup_table timelib_timezone_utc[] = {
|
||||
{ "utc", 0, 0, "UTC" },
|
||||
};
|
||||
|
||||
static timelib_relunit const timelib_relunit_lookup[] = {
|
||||
{ "ms", TIMELIB_MICROSEC, 1000 },
|
||||
{ "msec", TIMELIB_MICROSEC, 1000 },
|
||||
{ "msecs", TIMELIB_MICROSEC, 1000 },
|
||||
{ "millisecond", TIMELIB_MICROSEC, 1000 },
|
||||
{ "milliseconds", TIMELIB_MICROSEC, 1000 },
|
||||
{ "µs", TIMELIB_MICROSEC, 1 },
|
||||
{ "usec", TIMELIB_MICROSEC, 1 },
|
||||
{ "usecs", TIMELIB_MICROSEC, 1 },
|
||||
{ "µsec", TIMELIB_MICROSEC, 1 },
|
||||
{ "µsecs", TIMELIB_MICROSEC, 1 },
|
||||
{ "microsecond", TIMELIB_MICROSEC, 1 },
|
||||
{ "microseconds", TIMELIB_MICROSEC, 1 },
|
||||
{ "sec", TIMELIB_SECOND, 1 },
|
||||
{ "secs", TIMELIB_SECOND, 1 },
|
||||
{ "second", TIMELIB_SECOND, 1 },
|
||||
@ -342,37 +332,41 @@ uchar *fill(Scanner *s, uchar *cursor){
|
||||
}
|
||||
#endif
|
||||
|
||||
static void add_warning(Scanner *s, char *error)
|
||||
static void add_warning(Scanner *s, int error_code, char *error)
|
||||
{
|
||||
s->errors->warning_count++;
|
||||
s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message));
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].error_code = error_code;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].position = s->tok ? s->tok - s->str : 0;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].character = s->tok ? *s->tok : 0;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error);
|
||||
}
|
||||
|
||||
static void add_error(Scanner *s, char *error)
|
||||
static void add_error(Scanner *s, int error_code, char *error)
|
||||
{
|
||||
s->errors->error_count++;
|
||||
s->errors->error_messages = timelib_realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message));
|
||||
s->errors->error_messages[s->errors->error_count - 1].error_code = error_code;
|
||||
s->errors->error_messages[s->errors->error_count - 1].position = s->tok ? s->tok - s->str : 0;
|
||||
s->errors->error_messages[s->errors->error_count - 1].character = s->tok ? *s->tok : 0;
|
||||
s->errors->error_messages[s->errors->error_count - 1].message = timelib_strdup(error);
|
||||
}
|
||||
|
||||
static void add_pbf_warning(Scanner *s, char *error, char *sptr, char *cptr)
|
||||
static void add_pbf_warning(Scanner *s, int error_code, char *error, char *sptr, char *cptr)
|
||||
{
|
||||
s->errors->warning_count++;
|
||||
s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message));
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].error_code = error_code;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].position = cptr - sptr;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].character = *cptr;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error);
|
||||
}
|
||||
|
||||
static void add_pbf_error(Scanner *s, char *error, char *sptr, char *cptr)
|
||||
static void add_pbf_error(Scanner *s, int error_code, char *error, char *sptr, char *cptr)
|
||||
{
|
||||
s->errors->error_count++;
|
||||
s->errors->error_messages = timelib_realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message));
|
||||
s->errors->error_messages[s->errors->error_count - 1].error_code = error_code;
|
||||
s->errors->error_messages[s->errors->error_count - 1].position = cptr - sptr;
|
||||
s->errors->error_messages[s->errors->error_count - 1].character = *cptr;
|
||||
s->errors->error_messages[s->errors->error_count - 1].message = timelib_strdup(error);
|
||||
@ -492,7 +486,7 @@ static void timelib_skip_day_suffix(char **ptr)
|
||||
}
|
||||
}
|
||||
|
||||
static double timelib_get_frac_nr(char **ptr, int max_length)
|
||||
static timelib_sll timelib_get_frac_nr(char **ptr, int max_length)
|
||||
{
|
||||
char *begin, *end, *str;
|
||||
double tmp_nr = TIMELIB_UNSET;
|
||||
@ -510,12 +504,9 @@ static double timelib_get_frac_nr(char **ptr, int max_length)
|
||||
++len;
|
||||
}
|
||||
end = *ptr;
|
||||
str = timelib_calloc(1, end - begin + 1);
|
||||
memcpy(str, begin, end - begin);
|
||||
if (str[0] == ':') {
|
||||
str[0] = '.';
|
||||
}
|
||||
tmp_nr = strtod(str, NULL);
|
||||
str = timelib_calloc(1, end - begin);
|
||||
memcpy(str, begin + 1, end - begin - 1);
|
||||
tmp_nr = strtod(str, NULL) * pow(10, 7 - (end - begin));
|
||||
timelib_free(str);
|
||||
return tmp_nr;
|
||||
}
|
||||
@ -655,12 +646,13 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, S
|
||||
}
|
||||
|
||||
switch (relunit->unit) {
|
||||
case TIMELIB_SECOND: s->time->relative.s += amount * relunit->multiplier; break;
|
||||
case TIMELIB_MINUTE: s->time->relative.i += amount * relunit->multiplier; break;
|
||||
case TIMELIB_HOUR: s->time->relative.h += amount * relunit->multiplier; break;
|
||||
case TIMELIB_DAY: s->time->relative.d += amount * relunit->multiplier; break;
|
||||
case TIMELIB_MONTH: s->time->relative.m += amount * relunit->multiplier; break;
|
||||
case TIMELIB_YEAR: s->time->relative.y += amount * relunit->multiplier; break;
|
||||
case TIMELIB_MICROSEC: s->time->relative.us += amount * relunit->multiplier; break;
|
||||
case TIMELIB_SECOND: s->time->relative.s += amount * relunit->multiplier; break;
|
||||
case TIMELIB_MINUTE: s->time->relative.i += amount * relunit->multiplier; break;
|
||||
case TIMELIB_HOUR: s->time->relative.h += amount * relunit->multiplier; break;
|
||||
case TIMELIB_DAY: s->time->relative.d += amount * relunit->multiplier; break;
|
||||
case TIMELIB_MONTH: s->time->relative.m += amount * relunit->multiplier; break;
|
||||
case TIMELIB_YEAR: s->time->relative.y += amount * relunit->multiplier; break;
|
||||
|
||||
case TIMELIB_WEEKDAY:
|
||||
TIMELIB_HAVE_WEEKDAY_RELATIVE();
|
||||
@ -678,7 +670,7 @@ static void timelib_set_relative(char **ptr, timelib_sll amount, int behavior, S
|
||||
}
|
||||
}
|
||||
|
||||
const static timelib_tz_lookup_table* abbr_search(const char *word, timelib_long gmtoffset, int isdst)
|
||||
static const timelib_tz_lookup_table* abbr_search(const char *word, timelib_long gmtoffset, int isdst)
|
||||
{
|
||||
int first_found = 0;
|
||||
const timelib_tz_lookup_table *tp, *first_found_elem = NULL;
|
||||
@ -709,7 +701,7 @@ const static timelib_tz_lookup_table* abbr_search(const char *word, timelib_long
|
||||
/* Still didn't find anything, let's find the zone solely based on
|
||||
* offset/isdst then */
|
||||
for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) {
|
||||
if ((fmp->gmtoffset * 60) == gmtoffset && fmp->type == isdst) {
|
||||
if (fmp->gmtoffset == gmtoffset && fmp->type == isdst) {
|
||||
return fmp;
|
||||
}
|
||||
}
|
||||
@ -731,9 +723,9 @@ static timelib_long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, in
|
||||
memcpy(word, begin, end - begin);
|
||||
|
||||
if ((tp = abbr_search(word, -1, 0))) {
|
||||
value = -tp->gmtoffset / 60;
|
||||
value = tp->gmtoffset;
|
||||
*dst = tp->type;
|
||||
value += tp->type * 60;
|
||||
value -= tp->type * 3600;
|
||||
*found = 1;
|
||||
} else {
|
||||
*found = 0;
|
||||
@ -743,6 +735,42 @@ static timelib_long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, in
|
||||
return value;
|
||||
}
|
||||
|
||||
#define sHOUR(a) (int)(a * 3600)
|
||||
#define sMIN(a) (int)(a * 60)
|
||||
|
||||
static timelib_long timelib_parse_tz_cor(char **ptr)
|
||||
{
|
||||
char *begin = *ptr, *end;
|
||||
timelib_long tmp;
|
||||
|
||||
while (isdigit(**ptr) || **ptr == ':') {
|
||||
++*ptr;
|
||||
}
|
||||
end = *ptr;
|
||||
switch (end - begin) {
|
||||
case 1: /* H */
|
||||
case 2: /* HH */
|
||||
return sHOUR(strtol(begin, NULL, 10));
|
||||
break;
|
||||
case 3: /* H:M */
|
||||
case 4: /* H:MM, HH:M, HHMM */
|
||||
if (begin[1] == ':') {
|
||||
tmp = sHOUR(strtol(begin, NULL, 10)) + sMIN(strtol(begin + 2, NULL, 10));
|
||||
return tmp;
|
||||
} else if (begin[2] == ':') {
|
||||
tmp = sHOUR(strtol(begin, NULL, 10)) + sMIN(strtol(begin + 3, NULL, 10));
|
||||
return tmp;
|
||||
} else {
|
||||
tmp = strtol(begin, NULL, 10);
|
||||
return sHOUR(tmp / 100) + sMIN(tmp % 100);
|
||||
}
|
||||
case 5: /* HH:MM */
|
||||
tmp = sHOUR(strtol(begin, NULL, 10)) + sMIN(strtol(begin + 3, NULL, 10));
|
||||
return tmp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_wrapper)
|
||||
{
|
||||
timelib_tzinfo *res;
|
||||
@ -763,7 +791,7 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n
|
||||
*tz_not_found = 0;
|
||||
t->dst = 0;
|
||||
|
||||
retval = -1 * timelib_parse_tz_cor(ptr);
|
||||
retval = timelib_parse_tz_cor(ptr);
|
||||
} else if (**ptr == '-') {
|
||||
++*ptr;
|
||||
t->is_localtime = 1;
|
||||
@ -771,7 +799,7 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n
|
||||
*tz_not_found = 0;
|
||||
t->dst = 0;
|
||||
|
||||
retval = timelib_parse_tz_cor(ptr);
|
||||
retval = -1 * timelib_parse_tz_cor(ptr);
|
||||
} else {
|
||||
int found = 0;
|
||||
timelib_long offset = 0;
|
||||
@ -788,7 +816,9 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n
|
||||
|
||||
/* Otherwise, we look if we have a TimeZone identifier */
|
||||
if (!found || strcmp("UTC", tz_abbr) == 0) {
|
||||
if ((res = tz_wrapper(tz_abbr, tzdb)) != NULL) {
|
||||
int dummy_error_code;
|
||||
|
||||
if ((res = tz_wrapper(tz_abbr, tzdb, &dummy_error_code)) != NULL) {
|
||||
t->tz_info = res;
|
||||
t->zone_type = TIMELIB_ZONETYPE_ID;
|
||||
found++;
|
||||
@ -917,14 +947,15 @@ isoweek = year4 "-"? "W" weekofyear;
|
||||
exif = year4 ":" monthlz ":" daylz " " hour24lz ":" minutelz ":" secondlz;
|
||||
firstdayof = 'first day of';
|
||||
lastdayof = 'last day of';
|
||||
backof = 'back of ' hour24 space? meridian?;
|
||||
frontof = 'front of ' hour24 space? meridian?;
|
||||
backof = 'back of ' hour24 (space? meridian)?;
|
||||
frontof = 'front of ' hour24 (space? meridian)?;
|
||||
|
||||
/* Common Log Format: 10/Oct/2000:13:55:36 -0700 */
|
||||
clf = day "/" monthabbr "/" year4 ":" hour24lz ":" minutelz ":" secondlz space tzcorrection;
|
||||
|
||||
/* Timestamp format: @1126396800 */
|
||||
timestamp = "@" "-"? [0-9]+;
|
||||
timestampms = "@" "-"? [0-9]+ "." [0-9]{6};
|
||||
|
||||
/* To fix some ambiguities */
|
||||
dateshortwithtimeshort12 = datenoyear timeshort12;
|
||||
@ -938,7 +969,7 @@ dateshortwithtimelongtz = datenoyear iso8601normtz;
|
||||
*/
|
||||
reltextnumber = 'first'|'second'|'third'|'fourth'|'fifth'|'sixth'|'seventh'|'eight'|'eighth'|'ninth'|'tenth'|'eleventh'|'twelfth';
|
||||
reltexttext = 'next'|'last'|'previous'|'this';
|
||||
reltextunit = (('sec'|'second'|'min'|'minute'|'hour'|'day'|'fortnight'|'forthnight'|'month'|'year') 's'?) | 'weeks' | daytext;
|
||||
reltextunit = 'ms' | 'µs' | (('msec'|'millisecond'|'µsec'|'microsecond'|'usec'|'sec'|'second'|'min'|'minute'|'hour'|'day'|'fortnight'|'forthnight'|'month'|'year') 's'?) | 'weeks' | daytext;
|
||||
|
||||
relnumber = ([+-]*[ \t]*[0-9]+);
|
||||
relative = relnumber space? (reltextunit | 'week' );
|
||||
@ -1021,7 +1052,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
s->time->m = 1;
|
||||
s->time->d = 1;
|
||||
s->time->h = s->time->i = s->time->s = 0;
|
||||
s->time->f = 0.0;
|
||||
s->time->us = 0;
|
||||
s->time->relative.s += i;
|
||||
s->time->is_localtime = 1;
|
||||
s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
|
||||
@ -1032,6 +1063,34 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
return TIMELIB_RELATIVE;
|
||||
}
|
||||
|
||||
timestampms
|
||||
{
|
||||
timelib_ull i, us;
|
||||
|
||||
TIMELIB_INIT;
|
||||
TIMELIB_HAVE_RELATIVE();
|
||||
TIMELIB_UNHAVE_DATE();
|
||||
TIMELIB_UNHAVE_TIME();
|
||||
TIMELIB_HAVE_TZ();
|
||||
|
||||
i = timelib_get_unsigned_nr((char **) &ptr, 24);
|
||||
us = timelib_get_unsigned_nr((char **) &ptr, 24);
|
||||
s->time->y = 1970;
|
||||
s->time->m = 1;
|
||||
s->time->d = 1;
|
||||
s->time->h = s->time->i = s->time->s = 0;
|
||||
s->time->us = 0;
|
||||
s->time->relative.s += i;
|
||||
s->time->relative.us = us;
|
||||
s->time->is_localtime = 1;
|
||||
s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
|
||||
s->time->z = 0;
|
||||
s->time->dst = 0;
|
||||
|
||||
TIMELIB_DEINIT;
|
||||
return TIMELIB_RELATIVE;
|
||||
}
|
||||
|
||||
firstdayof | lastdayof
|
||||
{
|
||||
DEBUG_OUTPUT("firstdayof | lastdayof");
|
||||
@ -1122,7 +1181,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
s->time->s = timelib_get_nr((char **) &ptr, 2);
|
||||
|
||||
if (*ptr == ':' || *ptr == '.') {
|
||||
s->time->f = timelib_get_frac_nr((char **) &ptr, 8);
|
||||
s->time->us = timelib_get_frac_nr((char **) &ptr, 8);
|
||||
}
|
||||
}
|
||||
timelib_eat_spaces((char **) &ptr);
|
||||
@ -1143,14 +1202,14 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
s->time->s = timelib_get_nr((char **) &ptr, 2);
|
||||
|
||||
if (*ptr == '.') {
|
||||
s->time->f = timelib_get_frac_nr((char **) &ptr, 8);
|
||||
s->time->us = timelib_get_frac_nr((char **) &ptr, 8);
|
||||
}
|
||||
}
|
||||
|
||||
if (*ptr != '\0') {
|
||||
s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
|
||||
if (tz_not_found) {
|
||||
add_error(s, "The timezone could not be found in the database");
|
||||
add_error(s, TIMELIB_ERR_TZID_NOT_FOUND, "The timezone could not be found in the database");
|
||||
}
|
||||
}
|
||||
TIMELIB_DEINIT;
|
||||
@ -1172,7 +1231,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
break;
|
||||
default:
|
||||
TIMELIB_DEINIT;
|
||||
add_error(s, "Double time specification");
|
||||
add_error(s, TIMELIB_ERR_DOUBLE_TIME, "Double time specification");
|
||||
return TIMELIB_ERROR;
|
||||
}
|
||||
s->time->have_time++;
|
||||
@ -1216,7 +1275,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
if (*ptr != '\0') {
|
||||
s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
|
||||
if (tz_not_found) {
|
||||
add_error(s, "The timezone could not be found in the database");
|
||||
add_error(s, TIMELIB_ERR_TZID_NOT_FOUND, "The timezone could not be found in the database");
|
||||
}
|
||||
}
|
||||
TIMELIB_DEINIT;
|
||||
@ -1414,11 +1473,11 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
s->time->i = timelib_get_nr((char **) &ptr, 2);
|
||||
s->time->s = timelib_get_nr((char **) &ptr, 2);
|
||||
if (*ptr == '.') {
|
||||
s->time->f = timelib_get_frac_nr((char **) &ptr, 9);
|
||||
s->time->us = timelib_get_frac_nr((char **) &ptr, 9);
|
||||
if (*ptr) { /* timezone is optional */
|
||||
s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
|
||||
if (tz_not_found) {
|
||||
add_error(s, "The timezone could not be found in the database");
|
||||
add_error(s, TIMELIB_ERR_TZID_NOT_FOUND, "The timezone could not be found in the database");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1521,7 +1580,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
s->time->s = timelib_get_nr((char **) &ptr, 2);
|
||||
s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
|
||||
if (tz_not_found) {
|
||||
add_error(s, "The timezone could not be found in the database");
|
||||
add_error(s, TIMELIB_ERR_TZID_NOT_FOUND, "The timezone could not be found in the database");
|
||||
}
|
||||
TIMELIB_DEINIT;
|
||||
return TIMELIB_CLF;
|
||||
@ -1634,7 +1693,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
TIMELIB_HAVE_TZ();
|
||||
s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
|
||||
if (tz_not_found) {
|
||||
add_error(s, "The timezone could not be found in the database");
|
||||
add_error(s, TIMELIB_ERR_TZID_NOT_FOUND, "The timezone could not be found in the database");
|
||||
}
|
||||
TIMELIB_DEINIT;
|
||||
return TIMELIB_TIMEZONE;
|
||||
@ -1655,7 +1714,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
s->time->s = timelib_get_nr((char **) &ptr, 2);
|
||||
|
||||
if (*ptr == '.') {
|
||||
s->time->f = timelib_get_frac_nr((char **) &ptr, 8);
|
||||
s->time->us = timelib_get_frac_nr((char **) &ptr, 8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1680,14 +1739,14 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
s->time->s = timelib_get_nr((char **) &ptr, 2);
|
||||
|
||||
if (*ptr == '.') {
|
||||
s->time->f = timelib_get_frac_nr((char **) &ptr, 8);
|
||||
s->time->us = timelib_get_frac_nr((char **) &ptr, 8);
|
||||
}
|
||||
}
|
||||
|
||||
if (*ptr != '\0') {
|
||||
s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
|
||||
if (tz_not_found) {
|
||||
add_error(s, "The timezone could not be found in the database");
|
||||
add_error(s, TIMELIB_ERR_TZID_NOT_FOUND, "The timezone could not be found in the database");
|
||||
}
|
||||
}
|
||||
TIMELIB_DEINIT;
|
||||
@ -1723,7 +1782,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
|
||||
|
||||
any
|
||||
{
|
||||
add_error(s, "Unexpected character");
|
||||
add_error(s, TIMELIB_ERR_UNEXPECTED_CHARACTER, "Unexpected character");
|
||||
goto std;
|
||||
}
|
||||
*/
|
||||
@ -1754,13 +1813,13 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai
|
||||
}
|
||||
if (e - s < 0) {
|
||||
in.time = timelib_time_ctor();
|
||||
add_error(&in, "Empty string");
|
||||
add_error(&in, TIMELIB_ERR_EMPTY_STRING, "Empty string");
|
||||
if (errors) {
|
||||
*errors = in.errors;
|
||||
} else {
|
||||
timelib_error_container_dtor(in.errors);
|
||||
}
|
||||
in.time->y = in.time->d = in.time->m = in.time->h = in.time->i = in.time->s = in.time->f = in.time->dst = in.time->z = TIMELIB_UNSET;
|
||||
in.time->y = in.time->d = in.time->m = in.time->h = in.time->i = in.time->s = in.time->us = in.time->dst = in.time->z = TIMELIB_UNSET;
|
||||
in.time->is_localtime = in.time->zone_type = 0;
|
||||
return in.time;
|
||||
}
|
||||
@ -1778,7 +1837,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai
|
||||
in.time->h = TIMELIB_UNSET;
|
||||
in.time->i = TIMELIB_UNSET;
|
||||
in.time->s = TIMELIB_UNSET;
|
||||
in.time->f = TIMELIB_UNSET;
|
||||
in.time->us = TIMELIB_UNSET;
|
||||
in.time->z = TIMELIB_UNSET;
|
||||
in.time->dst = TIMELIB_UNSET;
|
||||
in.tzdb = tzdb;
|
||||
@ -1795,11 +1854,11 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai
|
||||
|
||||
/* do funky checking whether the parsed time was valid time */
|
||||
if (in.time->have_time && !timelib_valid_time( in.time->h, in.time->i, in.time->s)) {
|
||||
add_warning(&in, "The parsed time was invalid");
|
||||
add_warning(&in, TIMELIB_WARN_INVALID_TIME, "The parsed time was invalid");
|
||||
}
|
||||
/* do funky checking whether the parsed date was valid date */
|
||||
if (in.time->have_date && !timelib_valid_date( in.time->y, in.time->m, in.time->d)) {
|
||||
add_warning(&in, "The parsed date was invalid");
|
||||
add_warning(&in, TIMELIB_WARN_INVALID_DATE, "The parsed date was invalid");
|
||||
}
|
||||
|
||||
timelib_free(in.str);
|
||||
@ -1814,12 +1873,12 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai
|
||||
#define TIMELIB_CHECK_NUMBER \
|
||||
if (strchr("0123456789", *ptr) == NULL) \
|
||||
{ \
|
||||
add_pbf_error(s, "Unexpected data found.", string, begin); \
|
||||
add_pbf_error(s, TIMELIB_ERR_UNEXPECTED_DATA, "Unexpected data found.", string, begin); \
|
||||
}
|
||||
#define TIMELIB_CHECK_SIGNED_NUMBER \
|
||||
if (strchr("-0123456789", *ptr) == NULL) \
|
||||
{ \
|
||||
add_pbf_error(s, "Unexpected data found.", string, begin); \
|
||||
add_pbf_error(s, TIMELIB_ERR_UNEXPECTED_DATA, "Unexpected data found.", string, begin); \
|
||||
}
|
||||
|
||||
static void timelib_time_reset_fields(timelib_time *time)
|
||||
@ -1830,7 +1889,7 @@ static void timelib_time_reset_fields(timelib_time *time)
|
||||
time->m = 1;
|
||||
time->d = 1;
|
||||
time->h = time->i = time->s = 0;
|
||||
time->f = 0.0;
|
||||
time->us = 0;
|
||||
time->tz_info = NULL;
|
||||
}
|
||||
|
||||
@ -1844,7 +1903,7 @@ static void timelib_time_reset_unset_fields(timelib_time *time)
|
||||
if (time->h == TIMELIB_UNSET ) time->h = 0;
|
||||
if (time->i == TIMELIB_UNSET ) time->i = 0;
|
||||
if (time->s == TIMELIB_UNSET ) time->s = 0;
|
||||
if (time->f == TIMELIB_UNSET ) time->f = 0.0;
|
||||
if (time->us == TIMELIB_UNSET ) time->us = 0;
|
||||
}
|
||||
|
||||
timelib_time *timelib_parse_from_format(char *format, char *string, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
|
||||
@ -1871,7 +1930,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
in.time->h = TIMELIB_UNSET;
|
||||
in.time->i = TIMELIB_UNSET;
|
||||
in.time->s = TIMELIB_UNSET;
|
||||
in.time->f = TIMELIB_UNSET;
|
||||
in.time->us = TIMELIB_UNSET;
|
||||
in.time->z = TIMELIB_UNSET;
|
||||
in.time->dst = TIMELIB_UNSET;
|
||||
in.tzdb = tzdb;
|
||||
@ -1889,7 +1948,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
|
||||
tmprel = timelib_lookup_relunit((char **) &ptr);
|
||||
if (!tmprel) {
|
||||
add_pbf_error(s, "A textual day could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_TEXTUAL_DAY, "A textual day could not be found", string, begin);
|
||||
break;
|
||||
} else {
|
||||
in.time->have_relative = 1;
|
||||
@ -1903,7 +1962,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
case 'j': /* two digit day, without leading zero */
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
if ((s->time->d = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
|
||||
add_pbf_error(s, "A two digit day could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_TWO_DIGIT_DAY, "A two digit day could not be found", string, begin);
|
||||
}
|
||||
break;
|
||||
case 'S': /* day suffix, ignored, nor checked */
|
||||
@ -1912,7 +1971,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
case 'z': /* day of year - resets month (0 based) - also initializes everything else to !TIMELIB_UNSET */
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
if ((tmp = timelib_get_nr((char **) &ptr, 3)) == TIMELIB_UNSET) {
|
||||
add_pbf_error(s, "A three digit day-of-year could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_THREE_DIGIT_DAY_OF_YEAR, "A three digit day-of-year could not be found", string, begin);
|
||||
} else {
|
||||
s->time->m = 1;
|
||||
s->time->d = tmp + 1;
|
||||
@ -1924,14 +1983,14 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
case 'n': /* two digit month, without leading zero */
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
if ((s->time->m = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
|
||||
add_pbf_error(s, "A two digit month could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_TWO_DIGIT_MONTH, "A two digit month could not be found", string, begin);
|
||||
}
|
||||
break;
|
||||
case 'M': /* three letter month */
|
||||
case 'F': /* full month */
|
||||
tmp = timelib_lookup_month((char **) &ptr);
|
||||
if (!tmp) {
|
||||
add_pbf_error(s, "A textual month could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_TEXTUAL_MONTH, "A textual month could not be found", string, begin);
|
||||
} else {
|
||||
s->time->m = tmp;
|
||||
}
|
||||
@ -1941,7 +2000,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
int length = 0;
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
if ((s->time->y = timelib_get_nr_ex((char **) &ptr, 2, &length)) == TIMELIB_UNSET) {
|
||||
add_pbf_error(s, "A two digit year could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_TWO_DIGIT_YEAR, "A two digit year could not be found", string, begin);
|
||||
}
|
||||
TIMELIB_PROCESS_YEAR(s->time->y, length);
|
||||
}
|
||||
@ -1949,32 +2008,32 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
case 'Y': /* four digit year */
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
if ((s->time->y = timelib_get_nr((char **) &ptr, 4)) == TIMELIB_UNSET) {
|
||||
add_pbf_error(s, "A four digit year could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_FOUR_DIGIT_YEAR, "A four digit year could not be found", string, begin);
|
||||
}
|
||||
break;
|
||||
case 'g': /* two digit hour, with leading zero */
|
||||
case 'h': /* two digit hour, without leading zero */
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
|
||||
add_pbf_error(s, "A two digit hour could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_TWO_DIGIT_HOUR, "A two digit hour could not be found", string, begin);
|
||||
}
|
||||
if (s->time->h > 12) {
|
||||
add_pbf_error(s, "Hour can not be higher than 12", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_HOUR_LARGER_THAN_12, "Hour can not be higher than 12", string, begin);
|
||||
}
|
||||
break;
|
||||
case 'G': /* two digit hour, with leading zero */
|
||||
case 'H': /* two digit hour, without leading zero */
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
|
||||
add_pbf_error(s, "A two digit hour could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_TWO_DIGIT_HOUR, "A two digit hour could not be found", string, begin);
|
||||
}
|
||||
break;
|
||||
case 'a': /* am/pm/a.m./p.m. */
|
||||
case 'A': /* AM/PM/A.M./P.M. */
|
||||
if (s->time->h == TIMELIB_UNSET) {
|
||||
add_pbf_error(s, "Meridian can only come after an hour has been found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_MERIDIAN_BEFORE_HOUR, "Meridian can only come after an hour has been found", string, begin);
|
||||
} else if ((tmp = timelib_meridian_with_check((char **) &ptr, s->time->h)) == TIMELIB_UNSET) {
|
||||
add_pbf_error(s, "A meridian could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_MERIDIAN, "A meridian could not be found", string, begin);
|
||||
} else {
|
||||
s->time->h += tmp;
|
||||
}
|
||||
@ -1987,7 +2046,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
min = timelib_get_nr_ex((char **) &ptr, 2, &length);
|
||||
if (min == TIMELIB_UNSET || length != 2) {
|
||||
add_pbf_error(s, "A two digit minute could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_TWO_DIGIT_MINUTE, "A two digit minute could not be found", string, begin);
|
||||
} else {
|
||||
s->time->i = min;
|
||||
}
|
||||
@ -2001,13 +2060,13 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
|
||||
if (sec == TIMELIB_UNSET || length != 2) {
|
||||
add_pbf_error(s, "A two digit second could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_TWO_DIGIT_SECOND, "A two digit second could not be found", string, begin);
|
||||
} else {
|
||||
s->time->s = sec;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'u': /* up to six digit millisecond */
|
||||
case 'u': /* up to six digit microsecond */
|
||||
{
|
||||
double f;
|
||||
char *tptr;
|
||||
@ -2015,9 +2074,9 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
TIMELIB_CHECK_NUMBER;
|
||||
tptr = ptr;
|
||||
if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || (ptr - tptr < 1)) {
|
||||
add_pbf_error(s, "A six digit millisecond could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_SIX_DIGIT_MICROSECOND, "A six digit microsecond could not be found", string, begin);
|
||||
} else {
|
||||
s->time->f = (f / pow(10, (ptr - tptr)));
|
||||
s->time->us = (f * pow(10, 6 - (ptr - tptr)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2032,7 +2091,6 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
s->time->m = 1;
|
||||
s->time->d = 1;
|
||||
s->time->h = s->time->i = s->time->s = 0;
|
||||
s->time->f = 0.0;
|
||||
s->time->relative.s += tmp;
|
||||
s->time->is_localtime = 1;
|
||||
s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
|
||||
@ -2048,7 +2106,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
int tz_not_found;
|
||||
s->time->z = timelib_parse_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
|
||||
if (tz_not_found) {
|
||||
add_pbf_error(s, "The timezone could not be found in the database", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_TZID_NOT_FOUND, "The timezone could not be found in the database", string, begin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2057,7 +2115,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-' || *ptr == '(' || *ptr == ')') {
|
||||
++ptr;
|
||||
} else {
|
||||
add_pbf_error(s, "The separation symbol ([;:/.,-]) could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_SEP_SYMBOL, "The separation symbol ([;:/.,-]) could not be found", string, begin);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2072,7 +2130,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
if (*ptr == *fptr) {
|
||||
++ptr;
|
||||
} else {
|
||||
add_pbf_error(s, "The separation symbol could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_SEP_SYMBOL, "The separation symbol could not be found", string, begin);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2090,14 +2148,14 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
|
||||
case '\\': /* escaped char */
|
||||
if(!fptr[1]) {
|
||||
add_pbf_error(s, "Escaped character expected", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_EXPECTED_ESCAPE_CHAR, "Escaped character expected", string, begin);
|
||||
break;
|
||||
}
|
||||
fptr++;
|
||||
if (*ptr == *fptr) {
|
||||
++ptr;
|
||||
} else {
|
||||
add_pbf_error(s, "The escaped character could not be found", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_NO_ESCAPED_CHAR, "The escaped character could not be found", string, begin);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2111,7 +2169,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
|
||||
default:
|
||||
if (*fptr != *ptr) {
|
||||
add_pbf_error(s, "The format separator does not match", string, begin);
|
||||
add_pbf_error(s, TIMELIB_ERR_WRONG_FORMAT_SEP, "The format separator does not match", string, begin);
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
@ -2119,9 +2177,9 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
}
|
||||
if (*ptr) {
|
||||
if (allow_extra) {
|
||||
add_pbf_warning(s, "Trailing data", string, ptr);
|
||||
add_pbf_warning(s, TIMELIB_WARN_TRAILING_DATA, "Trailing data", string, ptr);
|
||||
} else {
|
||||
add_pbf_error(s, "Trailing data", string, ptr);
|
||||
add_pbf_error(s, TIMELIB_ERR_TRAILING_DATA, "Trailing data", string, ptr);
|
||||
}
|
||||
}
|
||||
/* ignore trailing +'s */
|
||||
@ -2142,7 +2200,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
break;
|
||||
|
||||
default:
|
||||
add_pbf_error(s, "Data missing", string, ptr);
|
||||
add_pbf_error(s, TIMELIB_ERR_DATA_MISSING, "Data missing", string, ptr);
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
@ -2165,13 +2223,13 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len,
|
||||
if (s->time->h != TIMELIB_UNSET && s->time->i != TIMELIB_UNSET &&
|
||||
s->time->s != TIMELIB_UNSET &&
|
||||
!timelib_valid_time( s->time->h, s->time->i, s->time->s)) {
|
||||
add_pbf_warning(s, "The parsed time was invalid", string, ptr);
|
||||
add_pbf_warning(s, TIMELIB_WARN_INVALID_TIME, "The parsed time was invalid", string, ptr);
|
||||
}
|
||||
/* do funky checking whether the parsed date was valid date */
|
||||
if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET &&
|
||||
s->time->d != TIMELIB_UNSET &&
|
||||
!timelib_valid_date( s->time->y, s->time->m, s->time->d)) {
|
||||
add_pbf_warning(s, "The parsed date was invalid", string, ptr);
|
||||
add_pbf_warning(s, TIMELIB_WARN_INVALID_DATE, "The parsed date was invalid", string, ptr);
|
||||
}
|
||||
|
||||
if (errors) {
|
||||
@ -2188,15 +2246,22 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
|
||||
parsed->h = 0;
|
||||
parsed->i = 0;
|
||||
parsed->s = 0;
|
||||
parsed->f = 0;
|
||||
parsed->us = 0;
|
||||
}
|
||||
if (
|
||||
parsed->y != TIMELIB_UNSET || parsed->m != TIMELIB_UNSET || parsed->d != TIMELIB_UNSET ||
|
||||
parsed->h != TIMELIB_UNSET || parsed->i != TIMELIB_UNSET || parsed->s != TIMELIB_UNSET
|
||||
) {
|
||||
if (parsed->us == TIMELIB_UNSET) parsed->us = 0;
|
||||
} else {
|
||||
if (parsed->us == TIMELIB_UNSET) parsed->us = now->us != TIMELIB_UNSET ? now->us : 0;
|
||||
}
|
||||
if (parsed->y == TIMELIB_UNSET) parsed->y = now->y != TIMELIB_UNSET ? now->y : 0;
|
||||
if (parsed->d == TIMELIB_UNSET) parsed->d = now->d != TIMELIB_UNSET ? now->d : 0;
|
||||
if (parsed->m == TIMELIB_UNSET) parsed->m = now->m != TIMELIB_UNSET ? now->m : 0;
|
||||
if (parsed->d == TIMELIB_UNSET) parsed->d = now->d != TIMELIB_UNSET ? now->d : 0;
|
||||
if (parsed->h == TIMELIB_UNSET) parsed->h = now->h != TIMELIB_UNSET ? now->h : 0;
|
||||
if (parsed->i == TIMELIB_UNSET) parsed->i = now->i != TIMELIB_UNSET ? now->i : 0;
|
||||
if (parsed->s == TIMELIB_UNSET) parsed->s = now->s != TIMELIB_UNSET ? now->s : 0;
|
||||
if (parsed->f == TIMELIB_UNSET) parsed->f = now->f != TIMELIB_UNSET ? now->f : 0;
|
||||
if (parsed->z == TIMELIB_UNSET) parsed->z = now->z != TIMELIB_UNSET ? now->z : 0;
|
||||
if (parsed->dst == TIMELIB_UNSET) parsed->dst = now->dst != TIMELIB_UNSET ? now->dst : 0;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Generated by re2c 0.13.5 on Thu Aug 13 10:30:12 2015 */
|
||||
/* Generated by re2c 0.15.3 on Mon Aug 14 13:00:14 2017 */
|
||||
#line 1 "ext/date/lib/parse_iso_intervals.re"
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
@ -27,19 +27,10 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "timelib.h"
|
||||
#include "timelib_private.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define strtoll(s, f, b) _atoi64(s)
|
||||
#elif !defined(HAVE_STRTOLL)
|
||||
@ -50,15 +41,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define TIMELIB_UNSET -99999
|
||||
|
||||
#define TIMELIB_SECOND 1
|
||||
#define TIMELIB_MINUTE 2
|
||||
#define TIMELIB_HOUR 3
|
||||
#define TIMELIB_DAY 4
|
||||
#define TIMELIB_MONTH 5
|
||||
#define TIMELIB_YEAR 6
|
||||
|
||||
#define EOI 257
|
||||
|
||||
#define TIMELIB_PERIOD 260
|
||||
@ -90,8 +72,6 @@ typedef unsigned char uchar;
|
||||
#define YYDEBUG(s,c)
|
||||
#endif
|
||||
|
||||
#include "timelib_structs.h"
|
||||
|
||||
typedef struct Scanner {
|
||||
int fd;
|
||||
uchar *lim, *str, *ptr, *cur, *tok, *pos;
|
||||
@ -110,15 +90,6 @@ typedef struct Scanner {
|
||||
int have_end_date;
|
||||
} Scanner;
|
||||
|
||||
static void add_warning(Scanner *s, char *error)
|
||||
{
|
||||
s->errors->warning_count++;
|
||||
s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message));
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].position = s->tok ? s->tok - s->str : 0;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].character = s->tok ? *s->tok : 0;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error);
|
||||
}
|
||||
|
||||
static void add_error(Scanner *s, char *error)
|
||||
{
|
||||
s->errors->error_count++;
|
||||
@ -182,55 +153,6 @@ static timelib_ull timelib_get_unsigned_nr(char **ptr, int max_length)
|
||||
return dir * timelib_get_nr(ptr, max_length);
|
||||
}
|
||||
|
||||
static void timelib_eat_spaces(char **ptr)
|
||||
{
|
||||
while (**ptr == ' ' || **ptr == '\t') {
|
||||
++*ptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void timelib_eat_until_separator(char **ptr)
|
||||
{
|
||||
while (strchr(" \t.,:;/-0123456789", **ptr) == NULL) {
|
||||
++*ptr;
|
||||
}
|
||||
}
|
||||
|
||||
static timelib_long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb)
|
||||
{
|
||||
timelib_long retval = 0;
|
||||
|
||||
*tz_not_found = 0;
|
||||
|
||||
while (**ptr == ' ' || **ptr == '\t' || **ptr == '(') {
|
||||
++*ptr;
|
||||
}
|
||||
if ((*ptr)[0] == 'G' && (*ptr)[1] == 'M' && (*ptr)[2] == 'T' && ((*ptr)[3] == '+' || (*ptr)[3] == '-')) {
|
||||
*ptr += 3;
|
||||
}
|
||||
if (**ptr == '+') {
|
||||
++*ptr;
|
||||
t->is_localtime = 1;
|
||||
t->zone_type = TIMELIB_ZONETYPE_OFFSET;
|
||||
*tz_not_found = 0;
|
||||
t->dst = 0;
|
||||
|
||||
retval = -1 * timelib_parse_tz_cor(ptr);
|
||||
} else if (**ptr == '-') {
|
||||
++*ptr;
|
||||
t->is_localtime = 1;
|
||||
t->zone_type = TIMELIB_ZONETYPE_OFFSET;
|
||||
*tz_not_found = 0;
|
||||
t->dst = 0;
|
||||
|
||||
retval = timelib_parse_tz_cor(ptr);
|
||||
}
|
||||
while (**ptr == ')') {
|
||||
++*ptr;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
#define timelib_split_free(arg) { \
|
||||
int i; \
|
||||
for (i = 0; i < arg.c; i++) { \
|
||||
@ -254,49 +176,49 @@ static int scan(Scanner *s)
|
||||
std:
|
||||
s->tok = cursor;
|
||||
s->len = 0;
|
||||
#line 282 "ext/date/lib/parse_iso_intervals.re"
|
||||
#line 204 "ext/date/lib/parse_iso_intervals.re"
|
||||
|
||||
|
||||
|
||||
#line 262 "ext/date/lib/parse_iso_intervals.c"
|
||||
#line 184 "<stdout>"
|
||||
{
|
||||
YYCTYPE yych;
|
||||
unsigned int yyaccept = 0;
|
||||
static const unsigned char yybm[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
YYDEBUG(0, *YYCURSOR);
|
||||
if ((YYLIMIT - YYCURSOR) < 20) YYFILL(20);
|
||||
yych = *YYCURSOR;
|
||||
if (yych <= ',') {
|
||||
@ -321,30 +243,35 @@ std:
|
||||
if (yych != 'R') goto yy11;
|
||||
}
|
||||
}
|
||||
YYDEBUG(2, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
if ((yych = *YYCURSOR) <= '/') goto yy3;
|
||||
if (yych <= '9') goto yy98;
|
||||
yy3:
|
||||
#line 395 "ext/date/lib/parse_iso_intervals.re"
|
||||
YYDEBUG(3, *YYCURSOR);
|
||||
#line 317 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
add_error(s, "Unexpected character");
|
||||
goto std;
|
||||
}
|
||||
#line 334 "ext/date/lib/parse_iso_intervals.c"
|
||||
#line 258 "<stdout>"
|
||||
yy4:
|
||||
YYDEBUG(4, *YYCURSOR);
|
||||
yyaccept = 0;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yych <= '/') goto yy3;
|
||||
if (yych <= '9') goto yy59;
|
||||
goto yy3;
|
||||
yy5:
|
||||
YYDEBUG(5, *YYCURSOR);
|
||||
yyaccept = 1;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yych <= '/') goto yy6;
|
||||
if (yych <= '9') goto yy12;
|
||||
if (yych == 'T') goto yy14;
|
||||
yy6:
|
||||
#line 322 "ext/date/lib/parse_iso_intervals.re"
|
||||
YYDEBUG(6, *YYCURSOR);
|
||||
#line 244 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
timelib_sll nr;
|
||||
int in_time = 0;
|
||||
@ -385,26 +312,32 @@ yy6:
|
||||
TIMELIB_DEINIT;
|
||||
return TIMELIB_PERIOD;
|
||||
}
|
||||
#line 389 "ext/date/lib/parse_iso_intervals.c"
|
||||
#line 316 "<stdout>"
|
||||
yy7:
|
||||
YYDEBUG(7, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
#line 384 "ext/date/lib/parse_iso_intervals.re"
|
||||
YYDEBUG(8, *YYCURSOR);
|
||||
#line 306 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
goto std;
|
||||
}
|
||||
#line 396 "ext/date/lib/parse_iso_intervals.c"
|
||||
#line 325 "<stdout>"
|
||||
yy9:
|
||||
YYDEBUG(9, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
#line 389 "ext/date/lib/parse_iso_intervals.re"
|
||||
YYDEBUG(10, *YYCURSOR);
|
||||
#line 311 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
s->pos = cursor; s->line++;
|
||||
goto std;
|
||||
}
|
||||
#line 404 "ext/date/lib/parse_iso_intervals.c"
|
||||
#line 335 "<stdout>"
|
||||
yy11:
|
||||
YYDEBUG(11, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
goto yy3;
|
||||
yy12:
|
||||
YYDEBUG(12, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= 'L') {
|
||||
if (yych <= '9') {
|
||||
@ -421,13 +354,15 @@ yy12:
|
||||
}
|
||||
}
|
||||
yy13:
|
||||
YYDEBUG(13, *YYCURSOR);
|
||||
YYCURSOR = YYMARKER;
|
||||
if (yyaccept <= 0) {
|
||||
if (yyaccept == 0) {
|
||||
goto yy3;
|
||||
} else {
|
||||
goto yy6;
|
||||
}
|
||||
yy14:
|
||||
YYDEBUG(14, *YYCURSOR);
|
||||
yyaccept = 1;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yybm[0+yych] & 128) {
|
||||
@ -435,9 +370,11 @@ yy14:
|
||||
}
|
||||
goto yy6;
|
||||
yy15:
|
||||
YYDEBUG(15, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
|
||||
yych = *YYCURSOR;
|
||||
YYDEBUG(16, *YYCURSOR);
|
||||
if (yybm[0+yych] & 128) {
|
||||
goto yy15;
|
||||
}
|
||||
@ -449,23 +386,28 @@ yy15:
|
||||
if (yych != 'S') goto yy13;
|
||||
}
|
||||
yy17:
|
||||
YYDEBUG(17, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
goto yy6;
|
||||
yy18:
|
||||
YYDEBUG(18, *YYCURSOR);
|
||||
yyaccept = 1;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yych <= '/') goto yy6;
|
||||
if (yych <= '9') goto yy22;
|
||||
goto yy6;
|
||||
yy19:
|
||||
YYDEBUG(19, *YYCURSOR);
|
||||
yyaccept = 1;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yych <= '/') goto yy6;
|
||||
if (yych >= ':') goto yy6;
|
||||
yy20:
|
||||
YYDEBUG(20, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
|
||||
yych = *YYCURSOR;
|
||||
YYDEBUG(21, *YYCURSOR);
|
||||
if (yych <= 'L') {
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy20;
|
||||
@ -476,18 +418,22 @@ yy20:
|
||||
goto yy13;
|
||||
}
|
||||
yy22:
|
||||
YYDEBUG(22, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
||||
yych = *YYCURSOR;
|
||||
YYDEBUG(23, *YYCURSOR);
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy22;
|
||||
if (yych == 'S') goto yy17;
|
||||
goto yy13;
|
||||
yy24:
|
||||
YYDEBUG(24, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == 'T') goto yy14;
|
||||
goto yy6;
|
||||
yy25:
|
||||
YYDEBUG(25, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= 'L') {
|
||||
if (yych <= '9') {
|
||||
@ -507,6 +453,7 @@ yy25:
|
||||
}
|
||||
}
|
||||
yy26:
|
||||
YYDEBUG(26, *YYCURSOR);
|
||||
yyaccept = 1;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yych <= '/') goto yy6;
|
||||
@ -514,6 +461,7 @@ yy26:
|
||||
if (yych == 'T') goto yy14;
|
||||
goto yy6;
|
||||
yy27:
|
||||
YYDEBUG(27, *YYCURSOR);
|
||||
yyaccept = 1;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yych <= '/') goto yy6;
|
||||
@ -521,6 +469,7 @@ yy27:
|
||||
if (yych == 'T') goto yy14;
|
||||
goto yy6;
|
||||
yy28:
|
||||
YYDEBUG(28, *YYCURSOR);
|
||||
yyaccept = 1;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yych <= '/') goto yy6;
|
||||
@ -528,9 +477,11 @@ yy28:
|
||||
if (yych == 'T') goto yy14;
|
||||
goto yy6;
|
||||
yy29:
|
||||
YYDEBUG(29, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
|
||||
yych = *YYCURSOR;
|
||||
YYDEBUG(30, *YYCURSOR);
|
||||
if (yych <= 'D') {
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy29;
|
||||
@ -546,9 +497,11 @@ yy29:
|
||||
}
|
||||
}
|
||||
yy31:
|
||||
YYDEBUG(31, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
|
||||
yych = *YYCURSOR;
|
||||
YYDEBUG(32, *YYCURSOR);
|
||||
if (yych <= 'C') {
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy31;
|
||||
@ -559,14 +512,17 @@ yy31:
|
||||
goto yy13;
|
||||
}
|
||||
yy33:
|
||||
YYDEBUG(33, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
|
||||
yych = *YYCURSOR;
|
||||
YYDEBUG(34, *YYCURSOR);
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy33;
|
||||
if (yych == 'D') goto yy24;
|
||||
goto yy13;
|
||||
yy35:
|
||||
YYDEBUG(35, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= 'L') {
|
||||
if (yych <= '9') {
|
||||
@ -585,18 +541,22 @@ yy35:
|
||||
goto yy13;
|
||||
}
|
||||
}
|
||||
YYDEBUG(36, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != '-') goto yy39;
|
||||
YYDEBUG(37, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '0') goto yy40;
|
||||
if (yych <= '1') goto yy41;
|
||||
goto yy13;
|
||||
yy38:
|
||||
YYDEBUG(38, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
|
||||
yych = *YYCURSOR;
|
||||
yy39:
|
||||
YYDEBUG(39, *YYCURSOR);
|
||||
if (yych <= 'L') {
|
||||
if (yych <= '9') {
|
||||
if (yych <= '/') goto yy13;
|
||||
@ -616,17 +576,21 @@ yy39:
|
||||
}
|
||||
}
|
||||
yy40:
|
||||
YYDEBUG(40, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy42;
|
||||
goto yy13;
|
||||
yy41:
|
||||
YYDEBUG(41, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '3') goto yy13;
|
||||
yy42:
|
||||
YYDEBUG(42, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != '-') goto yy13;
|
||||
YYDEBUG(43, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '0') goto yy44;
|
||||
@ -634,55 +598,70 @@ yy42:
|
||||
if (yych <= '3') goto yy46;
|
||||
goto yy13;
|
||||
yy44:
|
||||
YYDEBUG(44, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy47;
|
||||
goto yy13;
|
||||
yy45:
|
||||
YYDEBUG(45, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy47;
|
||||
goto yy13;
|
||||
yy46:
|
||||
YYDEBUG(46, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '2') goto yy13;
|
||||
yy47:
|
||||
YYDEBUG(47, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != 'T') goto yy13;
|
||||
YYDEBUG(48, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '1') goto yy49;
|
||||
if (yych <= '2') goto yy50;
|
||||
goto yy13;
|
||||
yy49:
|
||||
YYDEBUG(49, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy51;
|
||||
goto yy13;
|
||||
yy50:
|
||||
YYDEBUG(50, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '5') goto yy13;
|
||||
yy51:
|
||||
YYDEBUG(51, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != ':') goto yy13;
|
||||
YYDEBUG(52, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '6') goto yy13;
|
||||
YYDEBUG(53, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= ':') goto yy13;
|
||||
YYDEBUG(54, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != ':') goto yy13;
|
||||
YYDEBUG(55, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '6') goto yy13;
|
||||
YYDEBUG(56, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= ':') goto yy13;
|
||||
YYDEBUG(57, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
#line 364 "ext/date/lib/parse_iso_intervals.re"
|
||||
YYDEBUG(58, *YYCURSOR);
|
||||
#line 286 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
DEBUG_OUTPUT("combinedrep");
|
||||
TIMELIB_INIT;
|
||||
@ -701,14 +680,17 @@ yy51:
|
||||
TIMELIB_DEINIT;
|
||||
return TIMELIB_PERIOD;
|
||||
}
|
||||
#line 705 "ext/date/lib/parse_iso_intervals.c"
|
||||
#line 684 "<stdout>"
|
||||
yy59:
|
||||
YYDEBUG(59, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= ':') goto yy13;
|
||||
YYDEBUG(60, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= ':') goto yy13;
|
||||
YYDEBUG(61, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') {
|
||||
if (yych == '-') goto yy64;
|
||||
@ -719,33 +701,40 @@ yy59:
|
||||
goto yy13;
|
||||
}
|
||||
yy62:
|
||||
YYDEBUG(62, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '0') goto yy13;
|
||||
if (yych <= '9') goto yy85;
|
||||
goto yy13;
|
||||
yy63:
|
||||
YYDEBUG(63, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '2') goto yy85;
|
||||
goto yy13;
|
||||
yy64:
|
||||
YYDEBUG(64, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '0') goto yy65;
|
||||
if (yych <= '1') goto yy66;
|
||||
goto yy13;
|
||||
yy65:
|
||||
YYDEBUG(65, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '0') goto yy13;
|
||||
if (yych <= '9') goto yy67;
|
||||
goto yy13;
|
||||
yy66:
|
||||
YYDEBUG(66, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '3') goto yy13;
|
||||
yy67:
|
||||
YYDEBUG(67, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != '-') goto yy13;
|
||||
YYDEBUG(68, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '0') goto yy69;
|
||||
@ -753,58 +742,74 @@ yy67:
|
||||
if (yych <= '3') goto yy71;
|
||||
goto yy13;
|
||||
yy69:
|
||||
YYDEBUG(69, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '0') goto yy13;
|
||||
if (yych <= '9') goto yy72;
|
||||
goto yy13;
|
||||
yy70:
|
||||
YYDEBUG(70, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy72;
|
||||
goto yy13;
|
||||
yy71:
|
||||
YYDEBUG(71, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '2') goto yy13;
|
||||
yy72:
|
||||
YYDEBUG(72, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != 'T') goto yy13;
|
||||
YYDEBUG(73, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '1') goto yy74;
|
||||
if (yych <= '2') goto yy75;
|
||||
goto yy13;
|
||||
yy74:
|
||||
YYDEBUG(74, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy76;
|
||||
goto yy13;
|
||||
yy75:
|
||||
YYDEBUG(75, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '5') goto yy13;
|
||||
yy76:
|
||||
YYDEBUG(76, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != ':') goto yy13;
|
||||
YYDEBUG(77, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '6') goto yy13;
|
||||
YYDEBUG(78, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= ':') goto yy13;
|
||||
YYDEBUG(79, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != ':') goto yy13;
|
||||
YYDEBUG(80, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '6') goto yy13;
|
||||
YYDEBUG(81, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= ':') goto yy13;
|
||||
YYDEBUG(82, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != 'Z') goto yy13;
|
||||
yy83:
|
||||
YYDEBUG(83, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
#line 298 "ext/date/lib/parse_iso_intervals.re"
|
||||
YYDEBUG(84, *YYCURSOR);
|
||||
#line 220 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
timelib_time *current;
|
||||
|
||||
@ -827,8 +832,9 @@ yy83:
|
||||
TIMELIB_DEINIT;
|
||||
return TIMELIB_ISO_DATE;
|
||||
}
|
||||
#line 831 "ext/date/lib/parse_iso_intervals.c"
|
||||
#line 836 "<stdout>"
|
||||
yy85:
|
||||
YYDEBUG(85, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '0') goto yy86;
|
||||
@ -836,60 +842,75 @@ yy85:
|
||||
if (yych <= '3') goto yy88;
|
||||
goto yy13;
|
||||
yy86:
|
||||
YYDEBUG(86, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '0') goto yy13;
|
||||
if (yych <= '9') goto yy89;
|
||||
goto yy13;
|
||||
yy87:
|
||||
YYDEBUG(87, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy89;
|
||||
goto yy13;
|
||||
yy88:
|
||||
YYDEBUG(88, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '2') goto yy13;
|
||||
yy89:
|
||||
YYDEBUG(89, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != 'T') goto yy13;
|
||||
YYDEBUG(90, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '1') goto yy91;
|
||||
if (yych <= '2') goto yy92;
|
||||
goto yy13;
|
||||
yy91:
|
||||
YYDEBUG(91, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych <= '9') goto yy93;
|
||||
goto yy13;
|
||||
yy92:
|
||||
YYDEBUG(92, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '5') goto yy13;
|
||||
yy93:
|
||||
YYDEBUG(93, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '6') goto yy13;
|
||||
YYDEBUG(94, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= ':') goto yy13;
|
||||
YYDEBUG(95, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= '6') goto yy13;
|
||||
YYDEBUG(96, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy13;
|
||||
if (yych >= ':') goto yy13;
|
||||
YYDEBUG(97, *YYCURSOR);
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == 'Z') goto yy83;
|
||||
goto yy13;
|
||||
yy98:
|
||||
YYDEBUG(98, *YYCURSOR);
|
||||
++YYCURSOR;
|
||||
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
||||
yych = *YYCURSOR;
|
||||
YYDEBUG(99, *YYCURSOR);
|
||||
if (yych <= '/') goto yy100;
|
||||
if (yych <= '9') goto yy98;
|
||||
yy100:
|
||||
#line 287 "ext/date/lib/parse_iso_intervals.re"
|
||||
YYDEBUG(100, *YYCURSOR);
|
||||
#line 209 "ext/date/lib/parse_iso_intervals.re"
|
||||
{
|
||||
DEBUG_OUTPUT("recurrences");
|
||||
TIMELIB_INIT;
|
||||
@ -899,9 +920,9 @@ yy100:
|
||||
s->have_recurrences = 1;
|
||||
return TIMELIB_PERIOD;
|
||||
}
|
||||
#line 903 "ext/date/lib/parse_iso_intervals.c"
|
||||
#line 924 "<stdout>"
|
||||
}
|
||||
#line 399 "ext/date/lib/parse_iso_intervals.re"
|
||||
#line 321 "ext/date/lib/parse_iso_intervals.re"
|
||||
|
||||
}
|
||||
#ifdef PHP_WIN32
|
||||
@ -960,7 +981,7 @@ void timelib_strtointerval(char *s, size_t len,
|
||||
in.begin->h = TIMELIB_UNSET;
|
||||
in.begin->i = TIMELIB_UNSET;
|
||||
in.begin->s = TIMELIB_UNSET;
|
||||
in.begin->f = 0;
|
||||
in.begin->us = 0;
|
||||
in.begin->z = 0;
|
||||
in.begin->dst = 0;
|
||||
in.begin->is_localtime = 0;
|
||||
@ -973,7 +994,7 @@ void timelib_strtointerval(char *s, size_t len,
|
||||
in.end->h = TIMELIB_UNSET;
|
||||
in.end->i = TIMELIB_UNSET;
|
||||
in.end->s = TIMELIB_UNSET;
|
||||
in.end->f = 0;
|
||||
in.end->us = 0;
|
||||
in.end->z = 0;
|
||||
in.end->dst = 0;
|
||||
in.end->is_localtime = 0;
|
||||
|
@ -25,19 +25,10 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "timelib.h"
|
||||
#include "timelib_private.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define strtoll(s, f, b) _atoi64(s)
|
||||
#elif !defined(HAVE_STRTOLL)
|
||||
@ -48,15 +39,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define TIMELIB_UNSET -99999
|
||||
|
||||
#define TIMELIB_SECOND 1
|
||||
#define TIMELIB_MINUTE 2
|
||||
#define TIMELIB_HOUR 3
|
||||
#define TIMELIB_DAY 4
|
||||
#define TIMELIB_MONTH 5
|
||||
#define TIMELIB_YEAR 6
|
||||
|
||||
#define EOI 257
|
||||
|
||||
#define TIMELIB_PERIOD 260
|
||||
@ -88,8 +70,6 @@ typedef unsigned char uchar;
|
||||
#define YYDEBUG(s,c)
|
||||
#endif
|
||||
|
||||
#include "timelib_structs.h"
|
||||
|
||||
typedef struct Scanner {
|
||||
int fd;
|
||||
uchar *lim, *str, *ptr, *cur, *tok, *pos;
|
||||
@ -108,15 +88,6 @@ typedef struct Scanner {
|
||||
int have_end_date;
|
||||
} Scanner;
|
||||
|
||||
static void add_warning(Scanner *s, char *error)
|
||||
{
|
||||
s->errors->warning_count++;
|
||||
s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message));
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].position = s->tok ? s->tok - s->str : 0;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].character = s->tok ? *s->tok : 0;
|
||||
s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error);
|
||||
}
|
||||
|
||||
static void add_error(Scanner *s, char *error)
|
||||
{
|
||||
s->errors->error_count++;
|
||||
@ -180,55 +151,6 @@ static timelib_ull timelib_get_unsigned_nr(char **ptr, int max_length)
|
||||
return dir * timelib_get_nr(ptr, max_length);
|
||||
}
|
||||
|
||||
static void timelib_eat_spaces(char **ptr)
|
||||
{
|
||||
while (**ptr == ' ' || **ptr == '\t') {
|
||||
++*ptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void timelib_eat_until_separator(char **ptr)
|
||||
{
|
||||
while (strchr(" \t.,:;/-0123456789", **ptr) == NULL) {
|
||||
++*ptr;
|
||||
}
|
||||
}
|
||||
|
||||
static timelib_long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb)
|
||||
{
|
||||
timelib_long retval = 0;
|
||||
|
||||
*tz_not_found = 0;
|
||||
|
||||
while (**ptr == ' ' || **ptr == '\t' || **ptr == '(') {
|
||||
++*ptr;
|
||||
}
|
||||
if ((*ptr)[0] == 'G' && (*ptr)[1] == 'M' && (*ptr)[2] == 'T' && ((*ptr)[3] == '+' || (*ptr)[3] == '-')) {
|
||||
*ptr += 3;
|
||||
}
|
||||
if (**ptr == '+') {
|
||||
++*ptr;
|
||||
t->is_localtime = 1;
|
||||
t->zone_type = TIMELIB_ZONETYPE_OFFSET;
|
||||
*tz_not_found = 0;
|
||||
t->dst = 0;
|
||||
|
||||
retval = -1 * timelib_parse_tz_cor(ptr);
|
||||
} else if (**ptr == '-') {
|
||||
++*ptr;
|
||||
t->is_localtime = 1;
|
||||
t->zone_type = TIMELIB_ZONETYPE_OFFSET;
|
||||
*tz_not_found = 0;
|
||||
t->dst = 0;
|
||||
|
||||
retval = timelib_parse_tz_cor(ptr);
|
||||
}
|
||||
while (**ptr == ')') {
|
||||
++*ptr;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
#define timelib_split_free(arg) { \
|
||||
int i; \
|
||||
for (i = 0; i < arg.c; i++) { \
|
||||
@ -454,7 +376,7 @@ void timelib_strtointerval(char *s, size_t len,
|
||||
in.begin->h = TIMELIB_UNSET;
|
||||
in.begin->i = TIMELIB_UNSET;
|
||||
in.begin->s = TIMELIB_UNSET;
|
||||
in.begin->f = 0;
|
||||
in.begin->us = 0;
|
||||
in.begin->z = 0;
|
||||
in.begin->dst = 0;
|
||||
in.begin->is_localtime = 0;
|
||||
@ -467,7 +389,7 @@ void timelib_strtointerval(char *s, size_t len,
|
||||
in.end->h = TIMELIB_UNSET;
|
||||
in.end->i = TIMELIB_UNSET;
|
||||
in.end->s = TIMELIB_UNSET;
|
||||
in.end->f = 0;
|
||||
in.end->us = 0;
|
||||
in.end->z = 0;
|
||||
in.end->dst = 0;
|
||||
in.end->is_localtime = 0;
|
||||
|
@ -23,18 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "timelib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include "timelib_private.h"
|
||||
|
||||
#define TIMELIB_SUPPORTS_V2DATA
|
||||
#include "timezonedb.h"
|
||||
@ -49,13 +38,32 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define timelib_conv_int(l) (l)
|
||||
#else
|
||||
#define timelib_conv_int(l) ((l & 0x000000ff) << 24) + ((l & 0x0000ff00) << 8) + ((l & 0x00ff0000) >> 8) + ((l & 0xff000000) >> 24)
|
||||
#if defined(__s390__)
|
||||
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN
|
||||
# else
|
||||
# undef WORDS_BIGENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
static inline uint32_t timelib_conv_int_unsigned(uint32_t value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
#else
|
||||
static inline uint32_t timelib_conv_int_unsigned(uint32_t value)
|
||||
{
|
||||
return ((value & 0x000000ff) << 24) +
|
||||
((value & 0x0000ff00) << 8) +
|
||||
((value & 0x00ff0000) >> 8) +
|
||||
((value & 0xff000000) >> 24);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define timelib_conv_int_signed(value) ((int32_t) timelib_conv_int_unsigned((int32_t) value))
|
||||
|
||||
static int read_php_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
{
|
||||
uint32_t version;
|
||||
|
||||
@ -78,21 +86,67 @@ static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
return version;
|
||||
}
|
||||
|
||||
static int read_tzif_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
{
|
||||
uint32_t version;
|
||||
|
||||
/* read ID */
|
||||
switch ((*tzf)[4]) {
|
||||
case '\0':
|
||||
version = 0;
|
||||
break;
|
||||
case '2':
|
||||
version = 2;
|
||||
break;
|
||||
case '3':
|
||||
version = 3;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
*tzf += 5;
|
||||
|
||||
/* set BC flag and country code to default */
|
||||
tz->bc = 0;
|
||||
tz->location.country_code[0] = '?';
|
||||
tz->location.country_code[1] = '?';
|
||||
tz->location.country_code[2] = '\0';
|
||||
|
||||
/* skip rest of preamble */
|
||||
*tzf += 15;
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz, unsigned int *type)
|
||||
{
|
||||
/* read marker (TZif) or (PHP) */
|
||||
if (memcmp(*tzf, "PHP", 3) == 0) {
|
||||
*type = TIMELIB_TZINFO_PHP;
|
||||
return read_php_preamble(tzf, tz);
|
||||
} else if (memcmp(*tzf, "TZif", 4) == 0) {
|
||||
*type = TIMELIB_TZINFO_ZONEINFO;
|
||||
return read_tzif_preamble(tzf, tz);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void read_header(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
{
|
||||
uint32_t buffer[6];
|
||||
|
||||
memcpy(&buffer, *tzf, sizeof(buffer));
|
||||
tz->bit32.ttisgmtcnt = timelib_conv_int(buffer[0]);
|
||||
tz->bit32.ttisstdcnt = timelib_conv_int(buffer[1]);
|
||||
tz->bit32.leapcnt = timelib_conv_int(buffer[2]);
|
||||
tz->bit32.timecnt = timelib_conv_int(buffer[3]);
|
||||
tz->bit32.typecnt = timelib_conv_int(buffer[4]);
|
||||
tz->bit32.charcnt = timelib_conv_int(buffer[5]);
|
||||
tz->bit32.ttisgmtcnt = timelib_conv_int_unsigned(buffer[0]);
|
||||
tz->bit32.ttisstdcnt = timelib_conv_int_unsigned(buffer[1]);
|
||||
tz->bit32.leapcnt = timelib_conv_int_unsigned(buffer[2]);
|
||||
tz->bit32.timecnt = timelib_conv_int_unsigned(buffer[3]);
|
||||
tz->bit32.typecnt = timelib_conv_int_unsigned(buffer[4]);
|
||||
tz->bit32.charcnt = timelib_conv_int_unsigned(buffer[5]);
|
||||
*tzf += sizeof(buffer);
|
||||
}
|
||||
|
||||
static void skip_64bit_transistions(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
static void skip_64bit_transitions(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
{
|
||||
if (tz->bit64.timecnt) {
|
||||
*tzf += (sizeof(int64_t) * tz->bit64.timecnt);
|
||||
@ -100,7 +154,7 @@ static void skip_64bit_transistions(const unsigned char **tzf, timelib_tzinfo *t
|
||||
}
|
||||
}
|
||||
|
||||
static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
static int read_transitions(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
{
|
||||
int32_t *buffer = NULL;
|
||||
uint32_t i;
|
||||
@ -109,18 +163,22 @@ static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
if (tz->bit32.timecnt) {
|
||||
buffer = (int32_t*) timelib_malloc(tz->bit32.timecnt * sizeof(int32_t));
|
||||
if (!buffer) {
|
||||
return;
|
||||
return TIMELIB_ERROR_CANNOT_ALLOCATE;
|
||||
}
|
||||
memcpy(buffer, *tzf, sizeof(int32_t) * tz->bit32.timecnt);
|
||||
*tzf += (sizeof(int32_t) * tz->bit32.timecnt);
|
||||
for (i = 0; i < tz->bit32.timecnt; i++) {
|
||||
buffer[i] = timelib_conv_int(buffer[i]);
|
||||
buffer[i] = timelib_conv_int_signed(buffer[i]);
|
||||
/* Sanity check to see whether TS is just increasing */
|
||||
if (i > 0 && !(buffer[i] > buffer[i - 1])) {
|
||||
return TIMELIB_ERROR_CORRUPT_TRANSITIONS_DONT_INCREASE;
|
||||
}
|
||||
}
|
||||
|
||||
cbuffer = (unsigned char*) timelib_malloc(tz->bit32.timecnt * sizeof(unsigned char));
|
||||
if (!cbuffer) {
|
||||
timelib_free(buffer);
|
||||
return;
|
||||
return TIMELIB_ERROR_CANNOT_ALLOCATE;
|
||||
}
|
||||
memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->bit32.timecnt);
|
||||
*tzf += sizeof(unsigned char) * tz->bit32.timecnt;
|
||||
@ -128,6 +186,8 @@ static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
|
||||
tz->trans = buffer;
|
||||
tz->trans_idx = cbuffer;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void skip_64bit_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
@ -145,7 +205,7 @@ static void skip_64bit_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
}
|
||||
}
|
||||
|
||||
static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
static int read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
{
|
||||
unsigned char *buffer;
|
||||
int32_t *leap_buffer;
|
||||
@ -153,7 +213,7 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
|
||||
buffer = (unsigned char*) timelib_malloc(tz->bit32.typecnt * sizeof(unsigned char) * 6);
|
||||
if (!buffer) {
|
||||
return;
|
||||
return TIMELIB_ERROR_CANNOT_ALLOCATE;
|
||||
}
|
||||
memcpy(buffer, *tzf, sizeof(unsigned char) * 6 * tz->bit32.typecnt);
|
||||
*tzf += sizeof(unsigned char) * 6 * tz->bit32.typecnt;
|
||||
@ -161,12 +221,13 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
tz->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(struct ttinfo));
|
||||
if (!tz->type) {
|
||||
timelib_free(buffer);
|
||||
return;
|
||||
return TIMELIB_ERROR_CANNOT_ALLOCATE;
|
||||
}
|
||||
|
||||
for (i = 0; i < tz->bit32.typecnt; i++) {
|
||||
j = i * 6;
|
||||
tz->type[i].offset = (buffer[j] * 16777216) + (buffer[j + 1] * 65536) + (buffer[j + 2] * 256) + buffer[j + 3];
|
||||
tz->type[i].offset = 0;
|
||||
tz->type[i].offset += (int32_t) (((uint32_t) buffer[j]) << 24) + (buffer[j + 1] << 16) + (buffer[j + 2] << 8) + tz->type[i].offset + buffer[j + 3];
|
||||
tz->type[i].isdst = buffer[j + 4];
|
||||
tz->type[i].abbr_idx = buffer[j + 5];
|
||||
}
|
||||
@ -174,7 +235,7 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
|
||||
tz->timezone_abbr = (char*) timelib_malloc(tz->bit32.charcnt);
|
||||
if (!tz->timezone_abbr) {
|
||||
return;
|
||||
return TIMELIB_ERROR_CORRUPT_NO_ABBREVIATION;
|
||||
}
|
||||
memcpy(tz->timezone_abbr, *tzf, sizeof(char) * tz->bit32.charcnt);
|
||||
*tzf += sizeof(char) * tz->bit32.charcnt;
|
||||
@ -182,7 +243,7 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
if (tz->bit32.leapcnt) {
|
||||
leap_buffer = (int32_t *) timelib_malloc(tz->bit32.leapcnt * 2 * sizeof(int32_t));
|
||||
if (!leap_buffer) {
|
||||
return;
|
||||
return TIMELIB_ERROR_CANNOT_ALLOCATE;
|
||||
}
|
||||
memcpy(leap_buffer, *tzf, sizeof(int32_t) * tz->bit32.leapcnt * 2);
|
||||
*tzf += sizeof(int32_t) * tz->bit32.leapcnt * 2;
|
||||
@ -190,11 +251,11 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
tz->leap_times = (tlinfo*) timelib_malloc(tz->bit32.leapcnt * sizeof(tlinfo));
|
||||
if (!tz->leap_times) {
|
||||
timelib_free(leap_buffer);
|
||||
return;
|
||||
return TIMELIB_ERROR_CANNOT_ALLOCATE;
|
||||
}
|
||||
for (i = 0; i < tz->bit32.leapcnt; i++) {
|
||||
tz->leap_times[i].trans = timelib_conv_int(leap_buffer[i * 2]);
|
||||
tz->leap_times[i].offset = timelib_conv_int(leap_buffer[i * 2 + 1]);
|
||||
tz->leap_times[i].trans = timelib_conv_int_signed(leap_buffer[i * 2]);
|
||||
tz->leap_times[i].offset = timelib_conv_int_signed(leap_buffer[i * 2 + 1]);
|
||||
}
|
||||
timelib_free(leap_buffer);
|
||||
}
|
||||
@ -202,7 +263,7 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
if (tz->bit32.ttisstdcnt) {
|
||||
buffer = (unsigned char*) timelib_malloc(tz->bit32.ttisstdcnt * sizeof(unsigned char));
|
||||
if (!buffer) {
|
||||
return;
|
||||
return TIMELIB_ERROR_CANNOT_ALLOCATE;
|
||||
}
|
||||
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit32.ttisstdcnt);
|
||||
*tzf += sizeof(unsigned char) * tz->bit32.ttisstdcnt;
|
||||
@ -216,7 +277,7 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
if (tz->bit32.ttisgmtcnt) {
|
||||
buffer = (unsigned char*) timelib_malloc(tz->bit32.ttisgmtcnt * sizeof(unsigned char));
|
||||
if (!buffer) {
|
||||
return;
|
||||
return TIMELIB_ERROR_CANNOT_ALLOCATE;
|
||||
}
|
||||
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit32.ttisgmtcnt);
|
||||
*tzf += sizeof(unsigned char) * tz->bit32.ttisgmtcnt;
|
||||
@ -226,6 +287,8 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
}
|
||||
timelib_free(buffer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void skip_posix_string(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
@ -246,11 +309,11 @@ static void read_location(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
uint32_t comments_len;
|
||||
|
||||
memcpy(&buffer, *tzf, sizeof(buffer));
|
||||
tz->location.latitude = timelib_conv_int(buffer[0]);
|
||||
tz->location.latitude = timelib_conv_int_unsigned(buffer[0]);
|
||||
tz->location.latitude = (tz->location.latitude / 100000) - 90;
|
||||
tz->location.longitude = timelib_conv_int(buffer[1]);
|
||||
tz->location.longitude = timelib_conv_int_unsigned(buffer[1]);
|
||||
tz->location.longitude = (tz->location.longitude / 100000) - 180;
|
||||
comments_len = timelib_conv_int(buffer[2]);
|
||||
comments_len = timelib_conv_int_unsigned(buffer[2]);
|
||||
*tzf += sizeof(buffer);
|
||||
|
||||
tz->location.comments = timelib_malloc(comments_len + 1);
|
||||
@ -259,6 +322,15 @@ static void read_location(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
*tzf += comments_len;
|
||||
}
|
||||
|
||||
static void set_default_location_and_comments(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
{
|
||||
tz->location.latitude = 0;
|
||||
tz->location.longitude = 0;
|
||||
tz->location.comments = timelib_malloc(2);
|
||||
tz->location.comments[0] = '?';
|
||||
tz->location.comments[1] = '\0';
|
||||
}
|
||||
|
||||
void timelib_dump_tzinfo(timelib_tzinfo *tz)
|
||||
{
|
||||
uint32_t i;
|
||||
@ -307,7 +379,13 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const
|
||||
int left = 0, right = tzdb->index_size - 1;
|
||||
#ifdef HAVE_SETLOCALE
|
||||
char *cur_locale = NULL, *tmp;
|
||||
#endif
|
||||
|
||||
if (tzdb->index_size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SETLOCALE
|
||||
tmp = setlocale(LC_CTYPE, NULL);
|
||||
if (tmp) {
|
||||
cur_locale = timelib_strdup(tmp);
|
||||
@ -346,10 +424,10 @@ const timelib_tzdb *timelib_builtin_db(void)
|
||||
return &timezonedb_builtin;
|
||||
}
|
||||
|
||||
const timelib_tzdb_index_entry *timelib_timezone_builtin_identifiers_list(int *count)
|
||||
const timelib_tzdb_index_entry *timelib_timezone_identifiers_list(timelib_tzdb *tzdb, int *count)
|
||||
{
|
||||
*count = sizeof(timezonedb_idx_builtin) / sizeof(*timezonedb_idx_builtin);
|
||||
return timezonedb_idx_builtin;
|
||||
*count = tzdb->index_size;
|
||||
return tzdb->index;
|
||||
}
|
||||
|
||||
int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb)
|
||||
@ -358,9 +436,17 @@ int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb)
|
||||
return (seek_to_tz_position(&tzf, timezone, tzdb));
|
||||
}
|
||||
|
||||
static void skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
static int skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
{
|
||||
*tzf += 20;
|
||||
if (memcmp(*tzf, "TZif2", 5) == 0) {
|
||||
*tzf += 20;
|
||||
return 1;
|
||||
} else if (memcmp(*tzf, "TZif3", 5) == 0) {
|
||||
*tzf += 20;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void read_64bit_header(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
@ -368,43 +454,124 @@ static void read_64bit_header(const unsigned char **tzf, timelib_tzinfo *tz)
|
||||
uint32_t buffer[6];
|
||||
|
||||
memcpy(&buffer, *tzf, sizeof(buffer));
|
||||
tz->bit64.ttisgmtcnt = timelib_conv_int(buffer[0]);
|
||||
tz->bit64.ttisstdcnt = timelib_conv_int(buffer[1]);
|
||||
tz->bit64.leapcnt = timelib_conv_int(buffer[2]);
|
||||
tz->bit64.timecnt = timelib_conv_int(buffer[3]);
|
||||
tz->bit64.typecnt = timelib_conv_int(buffer[4]);
|
||||
tz->bit64.charcnt = timelib_conv_int(buffer[5]);
|
||||
tz->bit64.ttisgmtcnt = timelib_conv_int_unsigned(buffer[0]);
|
||||
tz->bit64.ttisstdcnt = timelib_conv_int_unsigned(buffer[1]);
|
||||
tz->bit64.leapcnt = timelib_conv_int_unsigned(buffer[2]);
|
||||
tz->bit64.timecnt = timelib_conv_int_unsigned(buffer[3]);
|
||||
tz->bit64.typecnt = timelib_conv_int_unsigned(buffer[4]);
|
||||
tz->bit64.charcnt = timelib_conv_int_unsigned(buffer[5]);
|
||||
*tzf += sizeof(buffer);
|
||||
}
|
||||
|
||||
timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb)
|
||||
static timelib_tzinfo* timelib_tzinfo_ctor(char *name)
|
||||
{
|
||||
timelib_tzinfo *t;
|
||||
t = timelib_calloc(1, sizeof(timelib_tzinfo));
|
||||
t->name = timelib_strdup(name);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb, int *error_code)
|
||||
{
|
||||
const unsigned char *tzf;
|
||||
timelib_tzinfo *tmp;
|
||||
int version;
|
||||
int transitions_result, types_result;
|
||||
unsigned int type; /* TIMELIB_TZINFO_PHP or TIMELIB_TZINFO_ZONEINFO */
|
||||
|
||||
if (seek_to_tz_position(&tzf, timezone, tzdb)) {
|
||||
tmp = timelib_tzinfo_ctor(timezone);
|
||||
|
||||
version = read_preamble(&tzf, tmp);
|
||||
version = read_preamble(&tzf, tmp, &type);
|
||||
if (version == -1) {
|
||||
*error_code = TIMELIB_ERROR_UNSUPPORTED_VERSION;
|
||||
timelib_tzinfo_dtor(tmp);
|
||||
return NULL;
|
||||
}
|
||||
//printf("- timezone: %s, version: %0d\n", timezone, version);
|
||||
|
||||
read_header(&tzf, tmp);
|
||||
read_transistions(&tzf, tmp);
|
||||
read_types(&tzf, tmp);
|
||||
if (version == 2) {
|
||||
skip_64bit_preamble(&tzf, tmp);
|
||||
if ((transitions_result = read_transitions(&tzf, tmp)) != 0) {
|
||||
/* Corrupt file as transitions do not increase */
|
||||
*error_code = transitions_result;
|
||||
timelib_tzinfo_dtor(tmp);
|
||||
return NULL;
|
||||
}
|
||||
if ((types_result = read_types(&tzf, tmp)) != 0) {
|
||||
*error_code = types_result;
|
||||
timelib_tzinfo_dtor(tmp);
|
||||
return NULL;
|
||||
}
|
||||
if (version == 2 || version == 3) {
|
||||
if (!skip_64bit_preamble(&tzf, tmp)) {
|
||||
/* 64 bit preamble is not in place */
|
||||
*error_code = TIMELIB_ERROR_CORRUPT_NO_64BIT_PREAMBLE;
|
||||
return NULL;
|
||||
}
|
||||
read_64bit_header(&tzf, tmp);
|
||||
skip_64bit_transistions(&tzf, tmp);
|
||||
skip_64bit_transitions(&tzf, tmp);
|
||||
skip_64bit_types(&tzf, tmp);
|
||||
skip_posix_string(&tzf, tmp);
|
||||
}
|
||||
read_location(&tzf, tmp);
|
||||
|
||||
if (type == TIMELIB_TZINFO_PHP) {
|
||||
read_location(&tzf, tmp);
|
||||
} else {
|
||||
set_default_location_and_comments(&tzf, tmp);
|
||||
}
|
||||
} else {
|
||||
*error_code = TIMELIB_ERROR_NO_SUCH_TIMEZONE;
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void timelib_tzinfo_dtor(timelib_tzinfo *tz)
|
||||
{
|
||||
TIMELIB_TIME_FREE(tz->name);
|
||||
TIMELIB_TIME_FREE(tz->trans);
|
||||
TIMELIB_TIME_FREE(tz->trans_idx);
|
||||
TIMELIB_TIME_FREE(tz->type);
|
||||
TIMELIB_TIME_FREE(tz->timezone_abbr);
|
||||
TIMELIB_TIME_FREE(tz->leap_times);
|
||||
TIMELIB_TIME_FREE(tz->location.comments);
|
||||
TIMELIB_TIME_FREE(tz);
|
||||
tz = NULL;
|
||||
}
|
||||
|
||||
timelib_tzinfo *timelib_tzinfo_clone(timelib_tzinfo *tz)
|
||||
{
|
||||
timelib_tzinfo *tmp = timelib_tzinfo_ctor(tz->name);
|
||||
tmp->bit32.ttisgmtcnt = tz->bit32.ttisgmtcnt;
|
||||
tmp->bit32.ttisstdcnt = tz->bit32.ttisstdcnt;
|
||||
tmp->bit32.leapcnt = tz->bit32.leapcnt;
|
||||
tmp->bit32.timecnt = tz->bit32.timecnt;
|
||||
tmp->bit32.typecnt = tz->bit32.typecnt;
|
||||
tmp->bit32.charcnt = tz->bit32.charcnt;
|
||||
|
||||
if (tz->bit32.timecnt) {
|
||||
tmp->trans = (int32_t *) timelib_malloc(tz->bit32.timecnt * sizeof(int32_t));
|
||||
tmp->trans_idx = (unsigned char*) timelib_malloc(tz->bit32.timecnt * sizeof(unsigned char));
|
||||
memcpy(tmp->trans, tz->trans, tz->bit32.timecnt * sizeof(int32_t));
|
||||
memcpy(tmp->trans_idx, tz->trans_idx, tz->bit32.timecnt * sizeof(unsigned char));
|
||||
}
|
||||
|
||||
tmp->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(struct ttinfo));
|
||||
memcpy(tmp->type, tz->type, tz->bit32.typecnt * sizeof(struct ttinfo));
|
||||
|
||||
tmp->timezone_abbr = (char*) timelib_malloc(tz->bit32.charcnt);
|
||||
memcpy(tmp->timezone_abbr, tz->timezone_abbr, tz->bit32.charcnt);
|
||||
|
||||
if (tz->bit32.leapcnt) {
|
||||
tmp->leap_times = (tlinfo*) timelib_malloc(tz->bit32.leapcnt * sizeof(tlinfo));
|
||||
memcpy(tmp->leap_times, tz->leap_times, tz->bit32.leapcnt * sizeof(tlinfo));
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib_sll *transition_time)
|
||||
{
|
||||
uint32_t i;
|
||||
@ -483,18 +650,18 @@ timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *
|
||||
int32_t offset = 0, leap_secs = 0;
|
||||
char *abbr;
|
||||
timelib_time_offset *tmp = timelib_time_offset_ctor();
|
||||
timelib_sll transistion_time;
|
||||
timelib_sll transition_time;
|
||||
|
||||
if ((to = fetch_timezone_offset(tz, ts, &transistion_time))) {
|
||||
if ((to = fetch_timezone_offset(tz, ts, &transition_time))) {
|
||||
offset = to->offset;
|
||||
abbr = &(tz->timezone_abbr[to->abbr_idx]);
|
||||
tmp->is_dst = to->isdst;
|
||||
tmp->transistion_time = transistion_time;
|
||||
tmp->transition_time = transition_time;
|
||||
} else {
|
||||
offset = 0;
|
||||
abbr = tz->timezone_abbr;
|
||||
tmp->is_dst = 0;
|
||||
tmp->transistion_time = 0;
|
||||
tmp->transition_time = 0;
|
||||
}
|
||||
|
||||
if ((tl = fetch_leaptime_offset(tz, ts))) {
|
||||
@ -516,7 +683,7 @@ timelib_sll timelib_get_current_offset(timelib_time *t)
|
||||
switch (t->zone_type) {
|
||||
case TIMELIB_ZONETYPE_ABBR:
|
||||
case TIMELIB_ZONETYPE_OFFSET:
|
||||
return (t->z + t->dst) * -60;
|
||||
return t->z + (t->dst * 3600);
|
||||
|
||||
case TIMELIB_ZONETYPE_ID:
|
||||
gmt_offset = timelib_get_time_zone_info(t->sse, t->tz_info);
|
||||
|
@ -23,18 +23,31 @@
|
||||
*/
|
||||
|
||||
#include "timelib.h"
|
||||
#include "timelib_private.h"
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
#define TIMELIB_TIME_FREE(m) \
|
||||
if (m) { \
|
||||
timelib_free(m); \
|
||||
m = NULL; \
|
||||
} \
|
||||
|
||||
#define TIMELIB_LLABS(y) (y < 0 ? (y * -1) : y)
|
||||
|
||||
#define HOUR(a) (int)(a * 60)
|
||||
const char *timelib_error_messages[8] = {
|
||||
"No error",
|
||||
"Can not allocate buffer for parsing",
|
||||
"Corrupt tzfile: The transitions in the file don't always increase",
|
||||
"Corrupt tzfile: The expected 64-bit preamble is missing",
|
||||
"Corrupt tzfile: No abbreviation could be found for a transition",
|
||||
"The version used in this timezone identifier is unsupported",
|
||||
"No timezone with this name could be found",
|
||||
};
|
||||
|
||||
const char *timelib_get_error_message(int error_code)
|
||||
{
|
||||
int entries = sizeof(timelib_error_messages) / sizeof(char*);
|
||||
|
||||
if (error_code >= 0 && error_code < entries) {
|
||||
return timelib_error_messages[error_code];
|
||||
}
|
||||
return "Unknown error code";
|
||||
}
|
||||
|
||||
timelib_time* timelib_time_ctor(void)
|
||||
{
|
||||
@ -44,12 +57,23 @@ timelib_time* timelib_time_ctor(void)
|
||||
return t;
|
||||
}
|
||||
|
||||
timelib_rel_time* timelib_rel_time_ctor(void)
|
||||
void timelib_time_dtor(timelib_time* t)
|
||||
{
|
||||
timelib_rel_time *t;
|
||||
t = timelib_calloc(1, sizeof(timelib_rel_time));
|
||||
TIMELIB_TIME_FREE(t->tz_abbr);
|
||||
TIMELIB_TIME_FREE(t);
|
||||
}
|
||||
|
||||
return t;
|
||||
int timelib_time_compare(timelib_time *t1, timelib_time *t2)
|
||||
{
|
||||
if (t1->sse == t2->sse) {
|
||||
if (t1->us == t2->us) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (t1->us < t2->us) ? -1 : 1;
|
||||
}
|
||||
|
||||
return (t1->sse < t2->sse) ? -1 : 1;
|
||||
}
|
||||
|
||||
timelib_time* timelib_time_clone(timelib_time *orig)
|
||||
@ -65,21 +89,17 @@ timelib_time* timelib_time_clone(timelib_time *orig)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
int timelib_time_compare(timelib_time *t1, timelib_time *t2)
|
||||
timelib_rel_time* timelib_rel_time_ctor(void)
|
||||
{
|
||||
if (t1->sse == t2->sse) {
|
||||
if (t1->f == t2->f) {
|
||||
return 0;
|
||||
}
|
||||
timelib_rel_time *t;
|
||||
t = timelib_calloc(1, sizeof(timelib_rel_time));
|
||||
|
||||
if (t1->sse < 0) {
|
||||
return (t1->f < t2->f) ? 1 : -1;
|
||||
} else {
|
||||
return (t1->f < t2->f) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
return (t1->sse < t2->sse) ? -1 : 1;
|
||||
void timelib_rel_time_dtor(timelib_rel_time* t)
|
||||
{
|
||||
TIMELIB_TIME_FREE(t);
|
||||
}
|
||||
|
||||
timelib_rel_time* timelib_rel_time_clone(timelib_rel_time *rel)
|
||||
@ -101,17 +121,6 @@ void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr)
|
||||
}
|
||||
}
|
||||
|
||||
void timelib_time_dtor(timelib_time* t)
|
||||
{
|
||||
TIMELIB_TIME_FREE(t->tz_abbr);
|
||||
TIMELIB_TIME_FREE(t);
|
||||
}
|
||||
|
||||
void timelib_rel_time_dtor(timelib_rel_time* t)
|
||||
{
|
||||
TIMELIB_TIME_FREE(t);
|
||||
}
|
||||
|
||||
timelib_time_offset* timelib_time_offset_ctor(void)
|
||||
{
|
||||
timelib_time_offset *t;
|
||||
@ -126,55 +135,6 @@ void timelib_time_offset_dtor(timelib_time_offset* t)
|
||||
TIMELIB_TIME_FREE(t);
|
||||
}
|
||||
|
||||
timelib_tzinfo* timelib_tzinfo_ctor(char *name)
|
||||
{
|
||||
timelib_tzinfo *t;
|
||||
t = timelib_calloc(1, sizeof(timelib_tzinfo));
|
||||
t->name = timelib_strdup(name);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
timelib_tzinfo *timelib_tzinfo_clone(timelib_tzinfo *tz)
|
||||
{
|
||||
timelib_tzinfo *tmp = timelib_tzinfo_ctor(tz->name);
|
||||
tmp->bit32.ttisgmtcnt = tz->bit32.ttisgmtcnt;
|
||||
tmp->bit32.ttisstdcnt = tz->bit32.ttisstdcnt;
|
||||
tmp->bit32.leapcnt = tz->bit32.leapcnt;
|
||||
tmp->bit32.timecnt = tz->bit32.timecnt;
|
||||
tmp->bit32.typecnt = tz->bit32.typecnt;
|
||||
tmp->bit32.charcnt = tz->bit32.charcnt;
|
||||
|
||||
tmp->trans = (int32_t *) timelib_malloc(tz->bit32.timecnt * sizeof(int32_t));
|
||||
tmp->trans_idx = (unsigned char*) timelib_malloc(tz->bit32.timecnt * sizeof(unsigned char));
|
||||
memcpy(tmp->trans, tz->trans, tz->bit32.timecnt * sizeof(int32_t));
|
||||
memcpy(tmp->trans_idx, tz->trans_idx, tz->bit32.timecnt * sizeof(unsigned char));
|
||||
|
||||
tmp->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(struct ttinfo));
|
||||
memcpy(tmp->type, tz->type, tz->bit32.typecnt * sizeof(struct ttinfo));
|
||||
|
||||
tmp->timezone_abbr = (char*) timelib_malloc(tz->bit32.charcnt);
|
||||
memcpy(tmp->timezone_abbr, tz->timezone_abbr, tz->bit32.charcnt);
|
||||
|
||||
tmp->leap_times = (tlinfo*) timelib_malloc(tz->bit32.leapcnt * sizeof(tlinfo));
|
||||
memcpy(tmp->leap_times, tz->leap_times, tz->bit32.leapcnt * sizeof(tlinfo));
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void timelib_tzinfo_dtor(timelib_tzinfo *tz)
|
||||
{
|
||||
TIMELIB_TIME_FREE(tz->name);
|
||||
TIMELIB_TIME_FREE(tz->trans);
|
||||
TIMELIB_TIME_FREE(tz->trans_idx);
|
||||
TIMELIB_TIME_FREE(tz->type);
|
||||
TIMELIB_TIME_FREE(tz->timezone_abbr);
|
||||
TIMELIB_TIME_FREE(tz->leap_times);
|
||||
TIMELIB_TIME_FREE(tz->location.comments);
|
||||
TIMELIB_TIME_FREE(tz);
|
||||
tz = NULL;
|
||||
}
|
||||
|
||||
char *timelib_get_tz_abbr_ptr(timelib_time *t)
|
||||
{
|
||||
if (!t->sse_uptodate) {
|
||||
@ -218,9 +178,24 @@ timelib_long timelib_date_to_int(timelib_time *d, int *error)
|
||||
|
||||
void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec)
|
||||
{
|
||||
*hour = floor(h);
|
||||
*min = floor((h - *hour) * 60);
|
||||
*sec = (h - *hour - ((float) *min / 60)) * 3600;
|
||||
if (h > 0) {
|
||||
*hour = floor(h);
|
||||
*min = floor((h - *hour) * 60);
|
||||
*sec = (h - *hour - ((float) *min / 60)) * 3600;
|
||||
} else {
|
||||
*hour = ceil(h);
|
||||
*min = 0 - ceil((h - *hour) * 60);
|
||||
*sec = 0 - (h - *hour - ((float) *min / -60)) * 3600;
|
||||
}
|
||||
}
|
||||
|
||||
void timelib_hms_to_decimal_hour(int hour, int min, int sec, double *h)
|
||||
{
|
||||
if (hour > 0) {
|
||||
*h = ((double)hour + (double)min / 60 + (double)sec / 3600);
|
||||
} else {
|
||||
*h = ((double)hour - (double)min / 60 - (double)sec / 3600);
|
||||
}
|
||||
}
|
||||
|
||||
void timelib_dump_date(timelib_time *d, int options)
|
||||
@ -230,8 +205,8 @@ void timelib_dump_date(timelib_time *d, int options)
|
||||
}
|
||||
printf("TS: %lld | %s%04lld-%02lld-%02lld %02lld:%02lld:%02lld",
|
||||
d->sse, d->y < 0 ? "-" : "", TIMELIB_LLABS(d->y), d->m, d->d, d->h, d->i, d->s);
|
||||
if (d->f > +0.0) {
|
||||
printf(" %.5f", d->f);
|
||||
if (d->us > 0) {
|
||||
printf(" 0.%06lld", d->us);
|
||||
}
|
||||
|
||||
if (d->is_localtime) {
|
||||
@ -260,6 +235,9 @@ void timelib_dump_date(timelib_time *d, int options)
|
||||
if (d->have_relative) {
|
||||
printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS",
|
||||
d->relative.y, d->relative.m, d->relative.d, d->relative.h, d->relative.i, d->relative.s);
|
||||
if (d->relative.us) {
|
||||
printf(" 0.%06lld", d->relative.us);
|
||||
}
|
||||
if (d->relative.first_last_day_of != 0) {
|
||||
switch (d->relative.first_last_day_of) {
|
||||
case 1:
|
||||
@ -307,36 +285,3 @@ void timelib_dump_rel_time(timelib_rel_time *d)
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
timelib_long timelib_parse_tz_cor(char **ptr)
|
||||
{
|
||||
char *begin = *ptr, *end;
|
||||
timelib_long tmp;
|
||||
|
||||
while (isdigit(**ptr) || **ptr == ':') {
|
||||
++*ptr;
|
||||
}
|
||||
end = *ptr;
|
||||
switch (end - begin) {
|
||||
case 1: /* H */
|
||||
case 2: /* HH */
|
||||
return HOUR(strtol(begin, NULL, 10));
|
||||
break;
|
||||
case 3: /* H:M */
|
||||
case 4: /* H:MM, HH:M, HHMM */
|
||||
if (begin[1] == ':') {
|
||||
tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
|
||||
return tmp;
|
||||
} else if (begin[2] == ':') {
|
||||
tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
|
||||
return tmp;
|
||||
} else {
|
||||
tmp = strtol(begin, NULL, 10);
|
||||
return HOUR(tmp / 100) + tmp % 100;
|
||||
}
|
||||
case 5: /* HH:MM */
|
||||
tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
|
||||
return tmp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -25,11 +25,283 @@
|
||||
#ifndef __TIMELIB_H__
|
||||
#define __TIMELIB_H__
|
||||
|
||||
#include "timelib_structs.h"
|
||||
#if HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#ifdef HAVE_TIMELIB_CONFIG_H
|
||||
# include "timelib_config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
# ifndef HAVE_INT32_T
|
||||
# if SIZEOF_INT == 4
|
||||
typedef int int32_t;
|
||||
# elif SIZEOF_LONG == 4
|
||||
typedef long int int32_t;
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef HAVE_UINT32_T
|
||||
# if SIZEOF_INT == 4
|
||||
typedef unsigned int uint32_t;
|
||||
# elif SIZEOF_LONG == 4
|
||||
typedef unsigned long int uint32_t;
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# if _MSC_VER >= 1600
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
# ifndef SIZEOF_INT
|
||||
# define SIZEOF_INT 4
|
||||
# endif
|
||||
# ifndef SIZEOF_LONG
|
||||
# define SIZEOF_LONG 4
|
||||
# endif
|
||||
# ifndef int32_t
|
||||
typedef __int32 int32_t;
|
||||
# endif
|
||||
# ifndef uint32_t
|
||||
typedef unsigned __int32 uint32_t;
|
||||
# endif
|
||||
# ifndef int64_t
|
||||
typedef __int64 int64_t;
|
||||
# endif
|
||||
# ifndef uint64_t
|
||||
typedef unsigned __int64 uint64_t;
|
||||
# endif
|
||||
# ifndef PRId32
|
||||
# define PRId32 "I32d"
|
||||
# endif
|
||||
# ifndef PRIu32
|
||||
# define PRIu32 "I32u"
|
||||
# endif
|
||||
# ifndef PRId64
|
||||
# define PRId64 "I64d"
|
||||
# endif
|
||||
# ifndef PRIu64
|
||||
# define PRIu64 "I64u"
|
||||
# endif
|
||||
# ifndef INT32_MAX
|
||||
#define INT32_MAX _I32_MAX
|
||||
# endif
|
||||
# ifndef INT32_MIN
|
||||
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||
# endif
|
||||
# ifndef UINT32_MAX
|
||||
#define UINT32_MAX _UI32_MAX
|
||||
# endif
|
||||
# ifndef INT64_MIN
|
||||
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||
# endif
|
||||
# ifndef INT64_MAX
|
||||
#define INT64_MAX _I64_MAX
|
||||
# endif
|
||||
# ifndef UINT64_MAX
|
||||
#define UINT64_MAX _UI64_MAX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (defined(__x86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64)) && !defined(TIMELIB_FORCE_LONG32)
|
||||
typedef int64_t timelib_long;
|
||||
typedef uint64_t timelib_ulong;
|
||||
# define TIMELIB_LONG_MAX INT64_MAX
|
||||
# define TIMELIB_LONG_MIN INT64_MIN
|
||||
# define TIMELIB_ULONG_MAX UINT64_MAX
|
||||
# define TIMELIB_LONG_FMT "%" PRId64
|
||||
# define TIMELIB_ULONG_FMT "%" PRIu64
|
||||
#else
|
||||
typedef int32_t timelib_long;
|
||||
typedef uint32_t timelib_ulong;
|
||||
# define TIMELIB_LONG_MAX INT32_MAX
|
||||
# define TIMELIB_LONG_MIN INT32_MIN
|
||||
# define TIMELIB_ULONG_MAX UINT32_MAX
|
||||
# define TIMELIB_LONG_FMT "%" PRId32
|
||||
# define TIMELIB_ULONG_FMT "%" PRIu32
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
typedef uint64_t timelib_ull;
|
||||
typedef int64_t timelib_sll;
|
||||
# define TIMELIB_LL_CONST(n) n ## i64
|
||||
#else
|
||||
typedef unsigned long long timelib_ull;
|
||||
typedef signed long long timelib_sll;
|
||||
# define TIMELIB_LL_CONST(n) n ## ll
|
||||
#endif
|
||||
|
||||
typedef struct ttinfo ttinfo;
|
||||
typedef struct tlinfo tlinfo;
|
||||
|
||||
typedef struct tlocinfo
|
||||
{
|
||||
char country_code[3];
|
||||
double latitude;
|
||||
double longitude;
|
||||
char *comments;
|
||||
} tlocinfo;
|
||||
|
||||
typedef struct timelib_tzinfo
|
||||
{
|
||||
char *name;
|
||||
struct {
|
||||
uint32_t ttisgmtcnt;
|
||||
uint32_t ttisstdcnt;
|
||||
uint32_t leapcnt;
|
||||
uint32_t timecnt;
|
||||
uint32_t typecnt;
|
||||
uint32_t charcnt;
|
||||
} bit32;
|
||||
struct {
|
||||
uint64_t ttisgmtcnt;
|
||||
uint64_t ttisstdcnt;
|
||||
uint64_t leapcnt;
|
||||
uint64_t timecnt;
|
||||
uint64_t typecnt;
|
||||
uint64_t charcnt;
|
||||
} bit64;
|
||||
|
||||
int32_t *trans;
|
||||
unsigned char *trans_idx;
|
||||
|
||||
ttinfo *type;
|
||||
char *timezone_abbr;
|
||||
|
||||
tlinfo *leap_times;
|
||||
unsigned char bc;
|
||||
tlocinfo location;
|
||||
} timelib_tzinfo;
|
||||
|
||||
typedef struct timelib_rel_time {
|
||||
timelib_sll y, m, d; /* Years, Months and Days */
|
||||
timelib_sll h, i, s; /* Hours, mInutes and Seconds */
|
||||
timelib_sll us; /* Microseconds */
|
||||
|
||||
int weekday; /* Stores the day in 'next monday' */
|
||||
int weekday_behavior; /* 0: the current day should *not* be counted when advancing forwards; 1: the current day *should* be counted */
|
||||
|
||||
int first_last_day_of;
|
||||
int invert; /* Whether the difference should be inverted */
|
||||
timelib_sll days; /* Contains the number of *days*, instead of Y-M-D differences */
|
||||
|
||||
struct {
|
||||
unsigned int type;
|
||||
timelib_sll amount;
|
||||
} special;
|
||||
|
||||
unsigned int have_weekday_relative, have_special_relative;
|
||||
} timelib_rel_time;
|
||||
|
||||
typedef struct timelib_time_offset {
|
||||
int32_t offset;
|
||||
unsigned int leap_secs;
|
||||
unsigned int is_dst;
|
||||
char *abbr;
|
||||
timelib_sll transition_time;
|
||||
} timelib_time_offset;
|
||||
|
||||
typedef struct timelib_time {
|
||||
timelib_sll y, m, d; /* Year, Month, Day */
|
||||
timelib_sll h, i, s; /* Hour, mInute, Second */
|
||||
timelib_sll us; /* Microseconds */
|
||||
int z; /* UTC offset in seconds */
|
||||
char *tz_abbr; /* Timezone abbreviation (display only) */
|
||||
timelib_tzinfo *tz_info; /* Timezone structure */
|
||||
signed int dst; /* Flag if we were parsing a DST zone */
|
||||
timelib_rel_time relative;
|
||||
|
||||
timelib_sll sse; /* Seconds since epoch */
|
||||
|
||||
unsigned int have_time, have_date, have_zone, have_relative, have_weeknr_day;
|
||||
|
||||
unsigned int sse_uptodate; /* !0 if the sse member is up to date with the date/time members */
|
||||
unsigned int tim_uptodate; /* !0 if the date/time members are up to date with the sse member */
|
||||
unsigned int is_localtime; /* 1 if the current struct represents localtime, 0 if it is in GMT */
|
||||
unsigned int zone_type; /* 1 time offset,
|
||||
* 3 TimeZone identifier,
|
||||
* 2 TimeZone abbreviation */
|
||||
} timelib_time;
|
||||
|
||||
typedef struct timelib_abbr_info {
|
||||
timelib_sll utc_offset;
|
||||
char *abbr;
|
||||
int dst;
|
||||
} timelib_abbr_info;
|
||||
|
||||
#define TIMELIB_WARN_MASK 0x1ff
|
||||
#define TIMELIB_ERR_MASK 0x2ff
|
||||
|
||||
#define TIMELIB_WARN_DOUBLE_TZ 0x101
|
||||
#define TIMELIB_WARN_INVALID_TIME 0x102
|
||||
#define TIMELIB_WARN_INVALID_DATE 0x103
|
||||
#define TIMELIB_WARN_TRAILING_DATA 0x11a
|
||||
|
||||
#define TIMELIB_ERR_DOUBLE_TZ 0x201
|
||||
#define TIMELIB_ERR_TZID_NOT_FOUND 0x202
|
||||
#define TIMELIB_ERR_DOUBLE_TIME 0x203
|
||||
#define TIMELIB_ERR_DOUBLE_DATE 0x204
|
||||
#define TIMELIB_ERR_UNEXPECTED_CHARACTER 0x205
|
||||
#define TIMELIB_ERR_EMPTY_STRING 0x206
|
||||
#define TIMELIB_ERR_UNEXPECTED_DATA 0x207
|
||||
#define TIMELIB_ERR_NO_TEXTUAL_DAY 0x208
|
||||
#define TIMELIB_ERR_NO_TWO_DIGIT_DAY 0x209
|
||||
#define TIMELIB_ERR_NO_THREE_DIGIT_DAY_OF_YEAR 0x20a
|
||||
#define TIMELIB_ERR_NO_TWO_DIGIT_MONTH 0x20b
|
||||
#define TIMELIB_ERR_NO_TEXTUAL_MONTH 0x20c
|
||||
#define TIMELIB_ERR_NO_TWO_DIGIT_YEAR 0x20d
|
||||
#define TIMELIB_ERR_NO_FOUR_DIGIT_YEAR 0x20e
|
||||
#define TIMELIB_ERR_NO_TWO_DIGIT_HOUR 0x20f
|
||||
#define TIMELIB_ERR_HOUR_LARGER_THAN_12 0x210
|
||||
#define TIMELIB_ERR_MERIDIAN_BEFORE_HOUR 0x211
|
||||
#define TIMELIB_ERR_NO_MERIDIAN 0x212
|
||||
#define TIMELIB_ERR_NO_TWO_DIGIT_MINUTE 0x213
|
||||
#define TIMELIB_ERR_NO_TWO_DIGIT_SECOND 0x214
|
||||
#define TIMELIB_ERR_NO_SIX_DIGIT_MICROSECOND 0x215
|
||||
#define TIMELIB_ERR_NO_SEP_SYMBOL 0x216
|
||||
#define TIMELIB_ERR_EXPECTED_ESCAPE_CHAR 0x217
|
||||
#define TIMELIB_ERR_NO_ESCAPED_CHAR 0x218
|
||||
#define TIMELIB_ERR_WRONG_FORMAT_SEP 0x219
|
||||
#define TIMELIB_ERR_TRAILING_DATA 0x21a
|
||||
#define TIMELIB_ERR_DATA_MISSING 0x21b
|
||||
|
||||
#define TIMELIB_ZONETYPE_OFFSET 1
|
||||
#define TIMELIB_ZONETYPE_ABBR 2
|
||||
#define TIMELIB_ZONETYPE_ID 3
|
||||
|
||||
typedef struct timelib_error_message {
|
||||
int error_code;
|
||||
int position;
|
||||
char character;
|
||||
char *message;
|
||||
} timelib_error_message;
|
||||
|
||||
typedef struct timelib_error_container {
|
||||
struct timelib_error_message *error_messages;
|
||||
struct timelib_error_message *warning_messages;
|
||||
int error_count;
|
||||
int warning_count;
|
||||
} timelib_error_container;
|
||||
|
||||
typedef struct _timelib_tz_lookup_table {
|
||||
char *name;
|
||||
int type;
|
||||
float gmtoffset;
|
||||
char *full_tz_name;
|
||||
} timelib_tz_lookup_table;
|
||||
|
||||
typedef struct _timelib_tzdb_index_entry {
|
||||
char *id;
|
||||
unsigned int pos;
|
||||
} timelib_tzdb_index_entry;
|
||||
|
||||
typedef struct _timelib_tzdb {
|
||||
char *version;
|
||||
int index_size;
|
||||
const timelib_tzdb_index_entry *index;
|
||||
const unsigned char *data;
|
||||
} timelib_tzdb;
|
||||
|
||||
#ifndef timelib_malloc
|
||||
# define timelib_malloc malloc
|
||||
# define timelib_realloc realloc
|
||||
@ -38,8 +310,8 @@
|
||||
# define timelib_free free
|
||||
#endif
|
||||
|
||||
#define TIMELIB_VERSION 201602
|
||||
#define TIMELIB_ASCII_VERSION "2016.02"
|
||||
#define TIMELIB_VERSION 201705
|
||||
#define TIMELIB_ASCII_VERSION "2017.05beta7"
|
||||
|
||||
#define TIMELIB_NONE 0x00
|
||||
#define TIMELIB_OVERRIDE_TIME 0x01
|
||||
@ -47,51 +319,172 @@
|
||||
|
||||
#define TIMELIB_UNSET -99999
|
||||
|
||||
#define TIMELIB_SPECIAL_WEEKDAY 0x01
|
||||
#define TIMELIB_SPECIAL_DAY_OF_WEEK_IN_MONTH 0x02
|
||||
#define TIMELIB_SPECIAL_LAST_DAY_OF_WEEK_IN_MONTH 0x03
|
||||
/* An entry for each of these error codes is also in the
|
||||
* timelib_error_messages array in timelib.c */
|
||||
#define TIMELIB_ERROR_NO_ERROR 0x00
|
||||
#define TIMELIB_ERROR_CANNOT_ALLOCATE 0x01
|
||||
#define TIMELIB_ERROR_CORRUPT_TRANSITIONS_DONT_INCREASE 0x02
|
||||
#define TIMELIB_ERROR_CORRUPT_NO_64BIT_PREAMBLE 0x03
|
||||
#define TIMELIB_ERROR_CORRUPT_NO_ABBREVIATION 0x04
|
||||
#define TIMELIB_ERROR_UNSUPPORTED_VERSION 0x05
|
||||
#define TIMELIB_ERROR_NO_SUCH_TIMEZONE 0x06
|
||||
|
||||
#define TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH 0x01
|
||||
#define TIMELIB_SPECIAL_LAST_DAY_OF_MONTH 0x02
|
||||
|
||||
#ifndef LONG_MAX
|
||||
#define LONG_MAX 2147483647L
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MIN
|
||||
#define LONG_MIN (- LONG_MAX - 1)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(strcasecmp)
|
||||
#define strcasecmp stricmp
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(strncasecmp)
|
||||
#define strncasecmp strnicmp
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Function pointers */
|
||||
typedef timelib_tzinfo* (*timelib_tz_get_wrapper)(char *tzname, const timelib_tzdb *tzdb);
|
||||
typedef timelib_tzinfo* (*timelib_tz_get_wrapper)(char *tzname, const timelib_tzdb *tzdb, int *error_code);
|
||||
|
||||
/* From dow.c */
|
||||
/* Calculates the day of the week from y, m, and d. 0=Sunday..6=Saturday */
|
||||
timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
|
||||
|
||||
/* Calculates the day of the ISO week from y, m, and d. 1=Monday, 7=Sunday */
|
||||
timelib_sll timelib_iso_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
|
||||
|
||||
/* Calculates the day of the year according to y-m-d. 0=Jan 1st..364/365=Dec
|
||||
* 31st */
|
||||
timelib_sll timelib_day_of_year(timelib_sll y, timelib_sll m, timelib_sll d);
|
||||
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d);
|
||||
|
||||
/* Calculates the day of the year according to y-w-dow. 0..364/365 */
|
||||
timelib_sll timelib_daynr_from_weeknr(timelib_sll iy, timelib_sll iw, timelib_sll id);
|
||||
|
||||
/* Calculates the number of days in month m for year y. 28..31 */
|
||||
timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m);
|
||||
|
||||
/* Calculates the ISO year and week from y, m, and d, into iw and iy */
|
||||
void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iw, timelib_sll *iy);
|
||||
|
||||
/* Calculates the ISO year, week, and day of week from y, m, and d, into iy,
|
||||
* iw, and id */
|
||||
void timelib_isodate_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iy, timelib_sll *iw, timelib_sll *id);
|
||||
|
||||
/* Calculates the year, month, and day from iy, iw, and iw, into y, m, and d */
|
||||
void timelib_date_from_isodate(timelib_sll iy, timelib_sll iw, timelib_sll id, timelib_sll *y, timelib_sll *m, timelib_sll *d);
|
||||
|
||||
/* Returns true if h, i and s fit in the range 00:00:00..23:59:59, false
|
||||
* otherwise */
|
||||
int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s);
|
||||
|
||||
/* Returns true if m fits in the range 1..12, and d fits in the range
|
||||
* 1..<days-in-month> for year y */
|
||||
int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d);
|
||||
|
||||
/* From parse_date.re */
|
||||
|
||||
/* Parses the date/time string in 's' with length 'len' into the constituent
|
||||
* parts of timelib_time*.
|
||||
*
|
||||
* Depending on the contents of the string 's', not all elements might be
|
||||
* filled. You can check whether a specific element has been parsed by
|
||||
* comparing with the TIMELIB_UNSET define.
|
||||
*
|
||||
* If errors occur, this function keeps already parsed elements in the
|
||||
* returned timelib_time* value.
|
||||
*
|
||||
* If the **errors points to a timelib_error_container variable, warnings
|
||||
* and errors will be recorded. You are responsible for freeing the stored
|
||||
* information with timelib_error_container_dtor(). To see whether errors have
|
||||
* occured, inspect errors->errors_count. To see whether warnings have occured,
|
||||
* inspect errors->warnings_count.
|
||||
*
|
||||
* The returned timelib_time* value is dynamically allocated and should be
|
||||
* freed with timelib_time_dtor().
|
||||
*/
|
||||
timelib_time *timelib_strtotime(char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper);
|
||||
|
||||
/* Parses the date/time string in 's' with length 'len' into the constituent
|
||||
* parts of timelib_time* according to the format in 'format'.
|
||||
*
|
||||
* Depending on the contents of the string 's', not all elements might be
|
||||
* filled. You can check whether a specific element has been parsed by
|
||||
* comparing with the TIMELIB_UNSET define.
|
||||
*
|
||||
* If errors occur, this function keeps already parsed elements in the
|
||||
* returned timelib_time* value.
|
||||
*
|
||||
* If the **errors points to a timelib_error_container variable, warnings
|
||||
* and errors will be recorded. You are responsible for freeing the stored
|
||||
* information with timelib_error_container_dtor(). To see whether errors have
|
||||
* occured, inspect errors->errors_count. To see whether warnings have occured,
|
||||
* inspect errors->warnings_count.
|
||||
*
|
||||
* The returned timelib_time* value is dynamically allocated and should be
|
||||
* freed with timelib_time_dtor().
|
||||
*/
|
||||
timelib_time *timelib_parse_from_format(char *format, char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper);
|
||||
|
||||
/* Fills the gaps in the parsed timelib_time with information from the reference date/time in 'now'
|
||||
*
|
||||
* If any of the 'parsed' y, m, d, h, i or s parameters is unset (TIMELIB_UNSET):
|
||||
* - if microtime (us) is unset, then the us of the parsed time is set to 0.
|
||||
* - else if microtime (us) is unset and 'now'->'us' is set, use it, otherwise use 0.
|
||||
*
|
||||
* For either of the 'parsed' y, m, d, h, i, s, z (utc offset in seconds) or
|
||||
* dst is unset, set it to the corresponding value in 'now' if set, otherwise
|
||||
* set it to 0.
|
||||
*
|
||||
* It duplicates tz_abbr if unset in 'parsed' but set in 'now'.
|
||||
*
|
||||
* It duplicates tz_info if unset in 'parsed', but set in 'now' unless
|
||||
* TIMELIB_NO_CLONE is passed, in which case only the pointer in 'parsed' is
|
||||
* set to 'now'.
|
||||
*
|
||||
* If the option TIMELIB_OVERRIDE_TIME is passed and the parsed date/time has
|
||||
* no time portion, the function will ignore the time aspect in 'now' and
|
||||
* instead fill it with zeros.
|
||||
*/
|
||||
void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options);
|
||||
|
||||
/* Tries to convert a time zone abbreviation, gmtoffset and/or isdst flag
|
||||
* combination to a time zone identifier.
|
||||
*
|
||||
* If 'abbr' is either 'utc' or 'gmt' (case insensitve) then "UTC" is
|
||||
* returned.
|
||||
*
|
||||
* It first uses the data in the timezonemap.h file to find a matching
|
||||
* abbreviation/GMT offset combination. If not found, it uses the data in
|
||||
* fallbackmap.h to match only the GMT offset/isdst flag to try to find a
|
||||
* match. If nothing is found, NULL is returned.
|
||||
*
|
||||
* The returned char* is not duplicated, and should not be freed.
|
||||
*/
|
||||
char *timelib_timezone_id_from_abbr(const char *abbr, timelib_long gmtoffset, int isdst);
|
||||
|
||||
/* Returns an array of known time zone abbreviations
|
||||
*
|
||||
* This file is generated from the time zone database through the
|
||||
* gettzmapping.php scripts, which requires that an up-to-date time zone
|
||||
* database is used with the PHP binary that runs the script.
|
||||
*
|
||||
* Each item in the returned list contains the abbreviation, a flag whether
|
||||
* it's an abbreviation used with DST, the UTC offset in seconds, and the name
|
||||
* of the time zone identifier that this abbreviation belongs to.
|
||||
*
|
||||
* The order for each specific abbreviation is controlled through the
|
||||
* preference list in the gettzmapping.php script. Time zones that match the
|
||||
* pattern ±\d{2,4} are excluded
|
||||
*/
|
||||
const timelib_tz_lookup_table *timelib_timezone_abbreviations_list(void);
|
||||
timelib_long timelib_parse_tz_cor(char**);
|
||||
|
||||
/**
|
||||
* DEPRECATED, but still used by PHP.
|
||||
*/
|
||||
timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_wrapper);
|
||||
|
||||
/* From parse_iso_intervals.re */
|
||||
|
||||
/**
|
||||
* Parses a subset of an ISO 8601 intervals specification string into its
|
||||
* constituent parts.
|
||||
*
|
||||
* If the **errors points to a timelib_error_container variable, warnings
|
||||
* and errors will be recorded. You are responsible for freeing the stored
|
||||
* information with timelib_error_container_dtor(). To see whether errors have
|
||||
* occured, inspect errors->errors_count. To see whether warnings have occured,
|
||||
* inspect errors->warnings_count.
|
||||
*/
|
||||
void timelib_strtointerval(char *s, size_t len,
|
||||
timelib_time **begin, timelib_time **end,
|
||||
timelib_rel_time **period, int *recurrences,
|
||||
@ -99,66 +492,395 @@ void timelib_strtointerval(char *s, size_t len,
|
||||
|
||||
|
||||
/* From tm2unixtime.c */
|
||||
|
||||
/**
|
||||
* Uses the y/m/d/h/i/s fields to calculate and store the equivalent timestamp
|
||||
* in the sse field.
|
||||
*
|
||||
* It uses the time zone information associated with 'time' to account for the
|
||||
* right UTC offset and/or DST rules. You can associate time zone information
|
||||
* with the timelib_set_timezone_* functions (see below).
|
||||
*
|
||||
* If the type is 'TIMELIB_ZONETYPE_ID' and there is no associated tzinfo, it
|
||||
* will use the second argument 'tzi' to provide the rules necessary to
|
||||
* calculate the right timestamp.
|
||||
*/
|
||||
void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi);
|
||||
|
||||
/**
|
||||
* Takes the information from the y/m/d/h/i/s fields and makes sure their
|
||||
* values are in the right range.
|
||||
*
|
||||
* If a value under- or overflows it will adjust the larger measure up (or
|
||||
* down). It also takes into account leap days.
|
||||
*/
|
||||
void timelib_do_normalize(timelib_time *base);
|
||||
|
||||
/**
|
||||
* Takes the information from the y/m/d/h/i/s fields of 'rt' and makes sure
|
||||
* their values are in the right range.
|
||||
*
|
||||
* If a value under- or overflows it will adjust the larger measure up (or
|
||||
* down). As this function operates on a *relative date/time*, it also takes
|
||||
* into account leap days and correctly accounts for the difference depending
|
||||
* on the base date/time in 'base'.
|
||||
*/
|
||||
void timelib_do_rel_normalize(timelib_time *base, timelib_rel_time *rt);
|
||||
|
||||
/* From unixtime2tm.c */
|
||||
int timelib_apply_localtime(timelib_time *t, unsigned int localtime);
|
||||
|
||||
/**
|
||||
* Takes the unix timestamp in seconds from 'ts' and populates the y/m/d/h/i/s
|
||||
* fields of 'tm' without taking time zones into account
|
||||
*/
|
||||
void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts);
|
||||
|
||||
/**
|
||||
* Takes the Unix timestamp from 'ts', and calculates the y/m/d/h/i/s fields
|
||||
* according to the time zone information attached to 'tm'.
|
||||
*/
|
||||
void timelib_unixtime2local(timelib_time *tm, timelib_sll ts);
|
||||
|
||||
/**
|
||||
* Takes the Unix timestamp stored in 'tm', and calculates the y/m/d/h/i/s
|
||||
* fields according to the time zone information attached to 'tm'.
|
||||
*/
|
||||
void timelib_update_from_sse(timelib_time *tm);
|
||||
|
||||
/**
|
||||
* Attaches the UTC offset as time zone information to 't'.
|
||||
*
|
||||
* 'utc_offset' is in seconds East of UTC.
|
||||
*/
|
||||
void timelib_set_timezone_from_offset(timelib_time *t, timelib_sll utc_offset);
|
||||
|
||||
/**
|
||||
* Attaches the information from 'abbr_info' as time zone information to 't'.
|
||||
*
|
||||
* The timelib_abbr_info struct contains an abbreviation ('abbr') which string
|
||||
* value is duplicated, as well as a 'utc_offset' and 'dst' flag. It only
|
||||
* supports a 'dst' change over of 1 hour.
|
||||
*/
|
||||
void timelib_set_timezone_from_abbr(timelib_time *t, timelib_abbr_info abbr_info);
|
||||
|
||||
/**
|
||||
* Attaches the time zone information in 'tz' to to 't'.
|
||||
*
|
||||
* It fetches the right UTC offset that is currently stored in the time
|
||||
* stamp field in 't' ('sse'), and assigns that to the 'z' field and 'dst'
|
||||
* field (whether DST is in effect at the time). It also sets the current
|
||||
* abbrevation to the 'tz_addr' field, making sure that if a value was already
|
||||
* set it was freed.
|
||||
*
|
||||
* The time zone information in 'tz' is *not* duplicated into the 't' field so
|
||||
* it should not be freed until all timelib_time* variables have been freed as
|
||||
* well.
|
||||
*/
|
||||
void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz);
|
||||
|
||||
/* From parse_tz.c */
|
||||
int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb);
|
||||
timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb);
|
||||
int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz);
|
||||
timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *tz);
|
||||
timelib_sll timelib_get_current_offset(timelib_time *t);
|
||||
void timelib_dump_tzinfo(timelib_tzinfo *tz);
|
||||
const timelib_tzdb *timelib_builtin_db(void);
|
||||
const timelib_tzdb_index_entry *timelib_timezone_builtin_identifiers_list(int *count);
|
||||
timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_wrapper);
|
||||
|
||||
/* From timelib.c */
|
||||
timelib_tzinfo* timelib_tzinfo_ctor(char *name);
|
||||
void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr);
|
||||
void timelib_time_tz_name_update(timelib_time* tm, char* tz_name);
|
||||
/**
|
||||
* Returns whether the time zone ID 'timezone' is available in the time zone
|
||||
* database as pointed to be 'tzdb'.
|
||||
*/
|
||||
int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb);
|
||||
|
||||
/**
|
||||
* Converts the binary stored time zone information from 'tzdb' for the time
|
||||
* zone 'timeozne' into a structure the library can use for calculations.
|
||||
*
|
||||
* The function can be used on both timelib_builtin_db as well as a time zone
|
||||
* db as opened by timelib_zoneinfo.
|
||||
* The function will return null upon failure, and also set an error code
|
||||
* through 'error_code'. 'error_code' must not be a null pointer. The error
|
||||
* code is one of the TIMELIB_ERROR_* constants as listed above. These error
|
||||
* constants can be converted into a string by timelib_get_error_message.
|
||||
*
|
||||
* This function allocates memory for the new time zone structure, which must
|
||||
* be freed after use. Although it is recommended that a cache of each used
|
||||
* time zone is kept.
|
||||
*/
|
||||
timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb, int *error_code);
|
||||
|
||||
/**
|
||||
* Frees up the resources allocated by 'timelib_parse_tzfile'.
|
||||
*/
|
||||
void timelib_tzinfo_dtor(timelib_tzinfo *tz);
|
||||
|
||||
/**
|
||||
* Deep-clones a timelib_tzinfo structure.
|
||||
*
|
||||
* This allocates resources that need to be freed with 'timelib_tzinfo_dtor'
|
||||
*/
|
||||
timelib_tzinfo* timelib_tzinfo_clone(timelib_tzinfo *tz);
|
||||
|
||||
/**
|
||||
* Returns whether DST is active with time zone 'tz' for the time stamp 'ts'.
|
||||
*
|
||||
* Returns 0 if DST is not active, 1 if DST is active, or -1 if no transitions
|
||||
* were available through 'tz'.
|
||||
*/
|
||||
int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz);
|
||||
|
||||
/**
|
||||
* Returns offset information with time zone 'tz' for the time stamp 'ts'.
|
||||
*
|
||||
* The returned information contains: the offset in seconds East of UTC (in
|
||||
* 'offset'), whether DST is active ('is_dst'), what the current time zone
|
||||
* abbreviation is ('abbr') and the transition time that got to this state (in
|
||||
* 'transistion_time');
|
||||
*/
|
||||
timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *tz);
|
||||
|
||||
/**
|
||||
* Returns the UTC offset currently applicable for the information stored in 't'.
|
||||
*
|
||||
* The value returned is the UTC offset in seconds East.
|
||||
*/
|
||||
timelib_sll timelib_get_current_offset(timelib_time *t);
|
||||
|
||||
/**
|
||||
* Displays debugging information about the time zone information in 'tz'.
|
||||
*/
|
||||
void timelib_dump_tzinfo(timelib_tzinfo *tz);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the built-in time zone database.
|
||||
*
|
||||
* You must *not* free the returned pointer as it is part of the text segment.
|
||||
*/
|
||||
const timelib_tzdb *timelib_builtin_db(void);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the start of an array containing a list of timezone identifiers.
|
||||
*
|
||||
* The amount of entries in the array is returned through the 'count' OUT parameter.
|
||||
*
|
||||
* Each entry contains the time zone ID ('id' field), and the position within the time zone
|
||||
* information ('pos' field). The pos field should not be used.
|
||||
*/
|
||||
const timelib_tzdb_index_entry *timelib_timezone_identifiers_list(timelib_tzdb *tzdb, int *count);
|
||||
|
||||
/* From parse_zoneinfo.c */
|
||||
|
||||
/**
|
||||
* Scans the directory and subdirectories of 'directory' for valid time zone files and builds
|
||||
* a time zone database out of these files.
|
||||
*
|
||||
* Typically, the directory should point to '/usr/share/zoneinfo'.
|
||||
*
|
||||
* Unlike 'timelib_builtin_db', the return value of this function must be freed
|
||||
* with the 'timelib_zoneinfo_dtor' function.
|
||||
*/
|
||||
timelib_tzdb *timelib_zoneinfo(char *directory);
|
||||
|
||||
/**
|
||||
* Frees up the resources as created through 'timelib_zoneinfo'.
|
||||
*
|
||||
* This function must be used to free up all the resources that have been
|
||||
* allocated while calling 'timelib_zoneinfo'.
|
||||
*/
|
||||
void timelib_zoneinfo_dtor(timelib_tzdb *tzdb);
|
||||
|
||||
/* From timelib.c */
|
||||
|
||||
/**
|
||||
* Returns a static string containing an error message belonging to a specific
|
||||
* error code.
|
||||
*/
|
||||
const char *timelib_get_error_message(int error_code);
|
||||
|
||||
/**
|
||||
* Allocates resources for the relative time structure.
|
||||
*
|
||||
* Must be freed with 'timelib_rel_time_dtor'.
|
||||
*/
|
||||
timelib_rel_time* timelib_rel_time_ctor(void);
|
||||
|
||||
/**
|
||||
* Frees up the resources as allocated through 'timelib_rel_time_ctor'.
|
||||
*/
|
||||
void timelib_rel_time_dtor(timelib_rel_time* t);
|
||||
|
||||
/**
|
||||
* Creates a new timelib_rel_time resource and copies over the information
|
||||
* from 'tz'.
|
||||
*
|
||||
* Must be freed with 'timelib_rel_time_dtor'.
|
||||
*/
|
||||
timelib_rel_time* timelib_rel_time_clone(timelib_rel_time *tz);
|
||||
|
||||
/**
|
||||
* Allocates resources for the time structure.
|
||||
*
|
||||
* Must be freed with 'timelib_time_dtor'.
|
||||
*/
|
||||
timelib_time* timelib_time_ctor(void);
|
||||
void timelib_time_set_option(timelib_time* tm, int option, void* option_value);
|
||||
|
||||
/**
|
||||
* Frees up the resources as allocated through 'timelib_time_ctor'.
|
||||
*/
|
||||
void timelib_time_dtor(timelib_time* t);
|
||||
|
||||
/**
|
||||
* Creates a new timelib_time resource and copies over the information
|
||||
* from 'orig'.
|
||||
*
|
||||
* Must be freed with 'timelib_time_dtor'.
|
||||
*/
|
||||
timelib_time* timelib_time_clone(timelib_time* orig);
|
||||
|
||||
/**
|
||||
* Compares two timelib_time structures and returns which one is earlier in
|
||||
* time.
|
||||
*
|
||||
* To decide which comes earlier it uses the 'sse' (Seconds Since Epoch) and
|
||||
* 'us' (microseconds) fields.
|
||||
*
|
||||
* Returns -1 if t1 < t2, 0 if t1 == t2, and -1 if t1 > t2.
|
||||
*/
|
||||
int timelib_time_compare(timelib_time *t1, timelib_time *t2);
|
||||
|
||||
/**
|
||||
* Allocates resources for the time offset structure.
|
||||
*
|
||||
* Must be freed with 'timelib_time_offset_dtor'.
|
||||
*/
|
||||
timelib_time_offset* timelib_time_offset_ctor(void);
|
||||
|
||||
/**
|
||||
* Frees up the resources as allocated through 'timelib_time_offset_ctor'.
|
||||
*/
|
||||
void timelib_time_offset_dtor(timelib_time_offset* t);
|
||||
|
||||
/**
|
||||
* Frees up the resources allocated while converting strings to timelib_time
|
||||
* structures with the timelib_strtotime and timelib_strtointerval functions.
|
||||
*/
|
||||
void timelib_error_container_dtor(timelib_error_container *errors);
|
||||
|
||||
/**
|
||||
* Converts the 'sse' value of 'd' to a timelib_long type.
|
||||
*
|
||||
* If the value fits in the TIMELIB_LONG_MIN and TIMELIB_LONG_MAX range, the
|
||||
* value is cast to (timelib_long) and returned. If *error is not a NULL
|
||||
* pointer, it will be set to 0.
|
||||
*
|
||||
* If the value does *not* fit in the range, the function returns 0 and if
|
||||
* *error is not a NULL pointer, it will be set to 1.
|
||||
*
|
||||
* timelib_long is a 32 bit signed long integer on 32 bit platforms, and a 64
|
||||
* bit signed long long integer on 64 bit platforms. In other words, it makes
|
||||
* sure that the value in 'sse' (which is always a signed long long 64 bit
|
||||
* integer) can be used safely outside of the library.
|
||||
*/
|
||||
timelib_long timelib_date_to_int(timelib_time *d, int *error);
|
||||
|
||||
/**
|
||||
* Displays debugging information about the date/time information stored in 'd'.
|
||||
*
|
||||
* 'options' is a bit field, where:
|
||||
* - 1 controls whether the relative time portion is shown.
|
||||
* - 2 controls whether the zone type is shown.
|
||||
*/
|
||||
void timelib_dump_date(timelib_time *d, int options);
|
||||
|
||||
/**
|
||||
* Displays debugging information about the relative time information stored
|
||||
* in 'd'.
|
||||
*/
|
||||
void timelib_dump_rel_time(timelib_rel_time *d);
|
||||
|
||||
/**
|
||||
* Converts a decimal hour into hour/min/sec components
|
||||
*/
|
||||
void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec);
|
||||
timelib_long timelib_parse_tz_cor(char **ptr);
|
||||
|
||||
/**
|
||||
* Converts hour/min/sec values into a decimal hour
|
||||
*/
|
||||
void timelib_hms_to_decimal_hour(int hour, int min, int sec, double *h);
|
||||
|
||||
/* from astro.c */
|
||||
double timelib_ts_to_juliandate(timelib_sll ts);
|
||||
|
||||
/**
|
||||
* Converts the Unix Epoch time stamp 'ts' to a Julian Day
|
||||
*
|
||||
* The value returned is the number of whole days since -4714-11-24T12:00:00 UTC
|
||||
* (in the proleptic Gregorian calendar):
|
||||
* https://en.wikipedia.org/wiki/Julian_day
|
||||
*/
|
||||
double timelib_ts_to_julianday(timelib_sll ts);
|
||||
|
||||
/**
|
||||
* Converts the Unix Epoch time stamp 'ts' to the J2000 epoch
|
||||
*
|
||||
* The value returned is the number of whole days since 2000-01-01T12:00:00
|
||||
* UTC: https://en.wikipedia.org/wiki/Epoch_(astronomy)#Julian_years_and_J2000
|
||||
*/
|
||||
double timelib_ts_to_j2000(timelib_sll ts);
|
||||
|
||||
/**
|
||||
* Calculates when the Sun is above a certain latitude.
|
||||
*
|
||||
* Parameters:
|
||||
* - time: A timelib_time time describing that needs to specific midnight for a
|
||||
* specific day.
|
||||
* - lon: The longitude of the observer (East positive, West negative).
|
||||
* - lat: The latitude of the observer (North positive, South negative).
|
||||
* - altit: The altitude. Set to -35/60 for rise/set, -6 for civil twilight,
|
||||
* -12 for nautical, and -18 for astronomical twilight.
|
||||
* - upper_limb: set to non-zero for rise/set calculations, and 0 for twilight
|
||||
* calculations.
|
||||
*
|
||||
* Out Parameters:
|
||||
* - h_rise: The decimal hour when the Sun rises
|
||||
* - h_set: The decimal hour when the Sun sets
|
||||
* - ts_rise: The Unix timestamp of the Sun rising
|
||||
* - ts_set: The Unix timestamp of the Sun setting
|
||||
* - ts_transit: The Unix timestmap of the Sun transitting through South
|
||||
*
|
||||
* Return Values:
|
||||
* - 0: The Sun rises and sets.
|
||||
* - +1: The Sun is always above the horizon. (ts_rise is set to ts_transit -
|
||||
* (12 * 3600); ts_set is set to ts_transit + (12 * 3600).
|
||||
* - -1: The Sun is awlays below the horizon. (ts_rise and ts_set are set
|
||||
* to ts_transit)
|
||||
*/
|
||||
int timelib_astro_rise_set_altitude(timelib_time *time, double lon, double lat, double altit, int upper_limb, double *h_rise, double *h_set, timelib_sll *ts_rise, timelib_sll *ts_set, timelib_sll *ts_transit);
|
||||
|
||||
/* from interval.c */
|
||||
|
||||
/**
|
||||
* Calculates the difference between two times
|
||||
*
|
||||
* The result is a timelib_rel_time structure that describes how you can
|
||||
* convert from 'one' to 'two' with 'timelib_add'. This does *not* necessarily
|
||||
* mean that you can go from 'two' to 'one' by using 'timelib_sub' due to the
|
||||
* way months and days are calculated.
|
||||
*/
|
||||
timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two);
|
||||
|
||||
/**
|
||||
* Adds the relative time information 'interval' to the base time 't'.
|
||||
*
|
||||
* This can be a relative time as created by 'timelib_diff', but also by more
|
||||
* complex statements such as "next workday".
|
||||
*/
|
||||
timelib_time *timelib_add(timelib_time *t, timelib_rel_time *interval);
|
||||
|
||||
/**
|
||||
* Subtracts the relative time information 'interval' to the base time 't'.
|
||||
*
|
||||
* This can be a relative time as created by 'timelib_diff'. Unlike with
|
||||
* 'timelib_add', this does not support more complex statements such as "next
|
||||
* workday".
|
||||
*/
|
||||
timelib_time *timelib_sub(timelib_time *t, timelib_rel_time *interval);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -69,12 +69,15 @@ TL_CHECK_INT_TYPE(uint32_t)
|
||||
|
||||
dnl Check for headers needed by timelib
|
||||
AC_CHECK_HEADERS([ \
|
||||
sys/time.h \
|
||||
sys/types.h \
|
||||
inttypes.h \
|
||||
stdint.h \
|
||||
dirent.h \
|
||||
string.h \
|
||||
stdlib.h
|
||||
strings.h \
|
||||
unistd.h \
|
||||
io.h
|
||||
])
|
||||
|
||||
dnl Check for strtoll, atoll
|
||||
AC_CHECK_FUNCS(strtoll atoll strftime)
|
||||
AC_CHECK_FUNCS(strtoll atoll strftime gettimeofday)
|
||||
|
158
ext/date/lib/timelib_private.h
Normal file
158
ext/date/lib/timelib_private.h
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Derick Rethans
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __TIMELIB_PRIVATE_H__
|
||||
#define __TIMELIB_PRIVATE_H__
|
||||
|
||||
#ifdef HAVE_SETLOCALE
|
||||
# include "locale.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIMELIB_CONFIG_H
|
||||
# include "timelib_config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_STDINT_H)
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_IO_H
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#define TIMELIB_SECOND 1
|
||||
#define TIMELIB_MINUTE 2
|
||||
#define TIMELIB_HOUR 3
|
||||
#define TIMELIB_DAY 4
|
||||
#define TIMELIB_MONTH 5
|
||||
#define TIMELIB_YEAR 6
|
||||
#define TIMELIB_WEEKDAY 7
|
||||
#define TIMELIB_SPECIAL 8
|
||||
#define TIMELIB_MICROSEC 9
|
||||
|
||||
#define TIMELIB_SPECIAL_WEEKDAY 0x01
|
||||
#define TIMELIB_SPECIAL_DAY_OF_WEEK_IN_MONTH 0x02
|
||||
#define TIMELIB_SPECIAL_LAST_DAY_OF_WEEK_IN_MONTH 0x03
|
||||
|
||||
#define TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH 0x01
|
||||
#define TIMELIB_SPECIAL_LAST_DAY_OF_MONTH 0x02
|
||||
|
||||
#define SECS_PER_ERA TIMELIB_LL_CONST(12622780800)
|
||||
#define SECS_PER_DAY 86400
|
||||
#define DAYS_PER_YEAR 365
|
||||
#define DAYS_PER_LYEAR 366
|
||||
/* 400*365 days + 97 leap days */
|
||||
#define DAYS_PER_LYEAR_PERIOD 146097
|
||||
#define YEARS_PER_LYEAR_PERIOD 400
|
||||
|
||||
#define TIMELIB_TZINFO_PHP 0x01
|
||||
#define TIMELIB_TZINFO_ZONEINFO 0x02
|
||||
|
||||
#define timelib_is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
|
||||
|
||||
#define TIMELIB_DEBUG(s) if (0) { s }
|
||||
|
||||
#define TIMELIB_TIME_FREE(m) \
|
||||
if (m) { \
|
||||
timelib_free(m); \
|
||||
m = NULL; \
|
||||
}
|
||||
|
||||
typedef struct ttinfo
|
||||
{
|
||||
int32_t offset;
|
||||
int isdst;
|
||||
unsigned int abbr_idx;
|
||||
|
||||
unsigned int isstdcnt;
|
||||
unsigned int isgmtcnt;
|
||||
} ttinfo;
|
||||
|
||||
typedef struct tlinfo
|
||||
{
|
||||
int32_t trans;
|
||||
int32_t offset;
|
||||
} tlinfo;
|
||||
|
||||
|
||||
#ifndef LONG_MAX
|
||||
#define LONG_MAX 2147483647L
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MIN
|
||||
#define LONG_MIN (- LONG_MAX - 1)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(strcasecmp)
|
||||
#define strcasecmp stricmp
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(strncasecmp)
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
/* From unixtime2tm.c */
|
||||
int timelib_apply_localtime(timelib_time *t, unsigned int localtime);
|
||||
|
||||
/* From parse_tz.c */
|
||||
void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr);
|
||||
|
||||
|
||||
#endif
|
@ -1,315 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Derick Rethans
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __TIMELIB_STRUCTS_H__
|
||||
#define __TIMELIB_STRUCTS_H__
|
||||
|
||||
#ifdef HAVE_TIMELIB_CONFIG_H
|
||||
# include "timelib_config.h"
|
||||
#endif
|
||||
|
||||
#ifndef TIMELIB_OMIT_STDINT
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INTTYPES_H)
|
||||
#include <inttypes.h>
|
||||
#elif defined(HAVE_STDINT_H)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
# ifndef HAVE_INT32_T
|
||||
# if SIZEOF_INT == 4
|
||||
typedef int int32_t;
|
||||
# elif SIZEOF_LONG == 4
|
||||
typedef long int int32_t;
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef HAVE_UINT32_T
|
||||
# if SIZEOF_INT == 4
|
||||
typedef unsigned int uint32_t;
|
||||
# elif SIZEOF_LONG == 4
|
||||
typedef unsigned long int uint32_t;
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# if _MSC_VER >= 1600
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
# ifndef SIZEOF_INT
|
||||
# define SIZEOF_INT 4
|
||||
# endif
|
||||
# ifndef SIZEOF_LONG
|
||||
# define SIZEOF_LONG 4
|
||||
# endif
|
||||
# ifndef int32_t
|
||||
typedef __int32 int32_t;
|
||||
# endif
|
||||
# ifndef uint32_t
|
||||
typedef unsigned __int32 uint32_t;
|
||||
# endif
|
||||
# ifndef int64_t
|
||||
typedef __int64 int64_t;
|
||||
# endif
|
||||
# ifndef uint64_t
|
||||
typedef unsigned __int64 uint64_t;
|
||||
# endif
|
||||
# ifndef PRId32
|
||||
# define PRId32 "I32d"
|
||||
# endif
|
||||
# ifndef PRIu32
|
||||
# define PRIu32 "I32u"
|
||||
# endif
|
||||
# ifndef PRId64
|
||||
# define PRId64 "I64d"
|
||||
# endif
|
||||
# ifndef PRIu64
|
||||
# define PRIu64 "I64u"
|
||||
# endif
|
||||
# ifndef INT32_MAX
|
||||
#define INT32_MAX _I32_MAX
|
||||
# endif
|
||||
# ifndef INT32_MIN
|
||||
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||
# endif
|
||||
# ifndef UINT32_MAX
|
||||
#define UINT32_MAX _UI32_MAX
|
||||
# endif
|
||||
# ifndef INT64_MIN
|
||||
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||
# endif
|
||||
# ifndef INT64_MAX
|
||||
#define INT64_MAX _I64_MAX
|
||||
# endif
|
||||
# ifndef UINT64_MAX
|
||||
#define UINT64_MAX _UI64_MAX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* TIMELIB_OMIT_STDINT */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64)
|
||||
typedef int64_t timelib_long;
|
||||
typedef uint64_t timelib_ulong;
|
||||
# define TIMELIB_LONG_MAX INT64_MAX
|
||||
# define TIMELIB_LONG_MIN INT64_MIN
|
||||
# define TIMELIB_ULONG_MAX UINT64_MAX
|
||||
# define TIMELIB_LONG_FMT "%" PRId64
|
||||
# define TIMELIB_ULONG_FMT "%" PRIu64
|
||||
#else
|
||||
typedef int32_t timelib_long;
|
||||
typedef uint32_t timelib_ulong;
|
||||
# define TIMELIB_LONG_MAX INT32_MAX
|
||||
# define TIMELIB_LONG_MIN INT32_MIN
|
||||
# define TIMELIB_ULONG_MAX UINT32_MAX
|
||||
# define TIMELIB_LONG_FMT "%" PRId32
|
||||
# define TIMELIB_ULONG_FMT "%" PRIu32
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
typedef uint64_t timelib_ull;
|
||||
typedef int64_t timelib_sll;
|
||||
# define TIMELIB_LL_CONST(n) n ## i64
|
||||
#else
|
||||
typedef unsigned long long timelib_ull;
|
||||
typedef signed long long timelib_sll;
|
||||
# define TIMELIB_LL_CONST(n) n ## ll
|
||||
#endif
|
||||
|
||||
typedef struct ttinfo
|
||||
{
|
||||
int32_t offset;
|
||||
int isdst;
|
||||
unsigned int abbr_idx;
|
||||
|
||||
unsigned int isstdcnt;
|
||||
unsigned int isgmtcnt;
|
||||
} ttinfo;
|
||||
|
||||
typedef struct tlinfo
|
||||
{
|
||||
int32_t trans;
|
||||
int32_t offset;
|
||||
} tlinfo;
|
||||
|
||||
typedef struct tlocinfo
|
||||
{
|
||||
char country_code[3];
|
||||
double latitude;
|
||||
double longitude;
|
||||
char *comments;
|
||||
} tlocinfo;
|
||||
|
||||
typedef struct timelib_tzinfo
|
||||
{
|
||||
char *name;
|
||||
struct {
|
||||
uint32_t ttisgmtcnt;
|
||||
uint32_t ttisstdcnt;
|
||||
uint32_t leapcnt;
|
||||
uint32_t timecnt;
|
||||
uint32_t typecnt;
|
||||
uint32_t charcnt;
|
||||
} bit32;
|
||||
struct {
|
||||
uint64_t ttisgmtcnt;
|
||||
uint64_t ttisstdcnt;
|
||||
uint64_t leapcnt;
|
||||
uint64_t timecnt;
|
||||
uint64_t typecnt;
|
||||
uint64_t charcnt;
|
||||
} bit64;
|
||||
|
||||
int32_t *trans;
|
||||
unsigned char *trans_idx;
|
||||
|
||||
ttinfo *type;
|
||||
char *timezone_abbr;
|
||||
|
||||
tlinfo *leap_times;
|
||||
unsigned char bc;
|
||||
tlocinfo location;
|
||||
} timelib_tzinfo;
|
||||
|
||||
typedef struct timelib_special {
|
||||
unsigned int type;
|
||||
timelib_sll amount;
|
||||
} timelib_special;
|
||||
|
||||
typedef struct timelib_rel_time {
|
||||
timelib_sll y, m, d; /* Years, Months and Days */
|
||||
timelib_sll h, i, s; /* Hours, mInutes and Seconds */
|
||||
|
||||
int weekday; /* Stores the day in 'next monday' */
|
||||
int weekday_behavior; /* 0: the current day should *not* be counted when advancing forwards; 1: the current day *should* be counted */
|
||||
|
||||
int first_last_day_of;
|
||||
int invert; /* Whether the difference should be inverted */
|
||||
timelib_sll days; /* Contains the number of *days*, instead of Y-M-D differences */
|
||||
|
||||
timelib_special special;
|
||||
unsigned int have_weekday_relative, have_special_relative;
|
||||
} timelib_rel_time;
|
||||
|
||||
typedef struct timelib_time_offset {
|
||||
int32_t offset;
|
||||
unsigned int leap_secs;
|
||||
unsigned int is_dst;
|
||||
char *abbr;
|
||||
timelib_sll transistion_time;
|
||||
} timelib_time_offset;
|
||||
|
||||
typedef struct timelib_time {
|
||||
timelib_sll y, m, d; /* Year, Month, Day */
|
||||
timelib_sll h, i, s; /* Hour, mInute, Second */
|
||||
double f; /* Fraction */
|
||||
int z; /* GMT offset in minutes */
|
||||
char *tz_abbr; /* Timezone abbreviation (display only) */
|
||||
timelib_tzinfo *tz_info; /* Timezone structure */
|
||||
signed int dst; /* Flag if we were parsing a DST zone */
|
||||
timelib_rel_time relative;
|
||||
|
||||
timelib_sll sse; /* Seconds since epoch */
|
||||
|
||||
unsigned int have_time, have_date, have_zone, have_relative, have_weeknr_day;
|
||||
|
||||
unsigned int sse_uptodate; /* !0 if the sse member is up to date with the date/time members */
|
||||
unsigned int tim_uptodate; /* !0 if the date/time members are up to date with the sse member */
|
||||
unsigned int is_localtime; /* 1 if the current struct represents localtime, 0 if it is in GMT */
|
||||
unsigned int zone_type; /* 1 time offset,
|
||||
* 3 TimeZone identifier,
|
||||
* 2 TimeZone abbreviation */
|
||||
} timelib_time;
|
||||
|
||||
typedef struct timelib_abbr_info {
|
||||
timelib_sll utc_offset;
|
||||
char *abbr;
|
||||
int dst;
|
||||
} timelib_abbr_info;
|
||||
|
||||
typedef struct timelib_error_message {
|
||||
int position;
|
||||
char character;
|
||||
char *message;
|
||||
} timelib_error_message;
|
||||
|
||||
typedef struct timelib_error_container {
|
||||
struct timelib_error_message *error_messages;
|
||||
struct timelib_error_message *warning_messages;
|
||||
int error_count;
|
||||
int warning_count;
|
||||
} timelib_error_container;
|
||||
|
||||
typedef struct _timelib_tz_lookup_table {
|
||||
char *name;
|
||||
int type;
|
||||
float gmtoffset;
|
||||
char *full_tz_name;
|
||||
} timelib_tz_lookup_table;
|
||||
|
||||
typedef struct _timelib_tzdb_index_entry {
|
||||
char *id;
|
||||
unsigned int pos;
|
||||
} timelib_tzdb_index_entry;
|
||||
|
||||
typedef struct _timelib_tzdb {
|
||||
char *version;
|
||||
int index_size;
|
||||
const timelib_tzdb_index_entry *index;
|
||||
const unsigned char *data;
|
||||
} timelib_tzdb;
|
||||
|
||||
#define TIMELIB_ZONETYPE_OFFSET 1
|
||||
#define TIMELIB_ZONETYPE_ABBR 2
|
||||
#define TIMELIB_ZONETYPE_ID 3
|
||||
|
||||
#define SECS_PER_ERA TIMELIB_LL_CONST(12622780800)
|
||||
#define SECS_PER_DAY 86400
|
||||
#define DAYS_PER_YEAR 365
|
||||
#define DAYS_PER_LYEAR 366
|
||||
/* 400*365 days + 97 leap days */
|
||||
#define DAYS_PER_LYEAR_PERIOD 146097
|
||||
#define YEARS_PER_LYEAR_PERIOD 400
|
||||
|
||||
#define timelib_is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
|
||||
|
||||
#define TIMELIB_DEBUG(s) if (0) { s }
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "timelib.h"
|
||||
#include "timelib_private.h"
|
||||
|
||||
/* jan feb mrt apr may jun jul aug sep oct nov dec */
|
||||
static int month_tab_leap[12] = { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
|
||||
@ -32,6 +33,18 @@ static int month_tab[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 24
|
||||
static int days_in_month_leap[13] = { 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
static int days_in_month[13] = { 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
static void do_range_limit_fraction(timelib_sll *fraction, timelib_sll *seconds)
|
||||
{
|
||||
if (*fraction < 0) {
|
||||
*fraction += 1000000;
|
||||
*seconds -= 1;
|
||||
}
|
||||
if (*fraction > 1000000) {
|
||||
*fraction -= 1000000;
|
||||
*seconds += 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void do_range_limit(timelib_sll start, timelib_sll end, timelib_sll adj, timelib_sll *a, timelib_sll *b)
|
||||
{
|
||||
if (*a < start) {
|
||||
@ -190,13 +203,47 @@ void timelib_do_rel_normalize(timelib_time *base, timelib_rel_time *rt)
|
||||
do_range_limit(0, 12, 12, &rt->m, &rt->y);
|
||||
}
|
||||
|
||||
#define EPOCH_DAY 719468
|
||||
|
||||
static void magic_date_calc(timelib_time *time)
|
||||
{
|
||||
timelib_sll y, ddd, mi, mm, dd, g;
|
||||
|
||||
/* The algorithm doesn't work before the year 1 */
|
||||
if (time->d < -719498) {
|
||||
return;
|
||||
}
|
||||
|
||||
g = time->d + EPOCH_DAY - 1;
|
||||
|
||||
y = (10000 * g + 14780) / 3652425;
|
||||
ddd = g - ((365*y) + (y/4) - (y/100) + (y/400));
|
||||
if (ddd < 0) {
|
||||
y--;
|
||||
ddd = g - ((365*y) + (y/4) - (y/100) + (y/400));
|
||||
}
|
||||
mi = (100 * ddd + 52) / 3060;
|
||||
mm = ((mi + 2) % 12) + 1;
|
||||
y = y + (mi + 2) / 12;
|
||||
dd = ddd - ((mi * 306 + 5) / 10) + 1;
|
||||
time->y = y;
|
||||
time->m = mm;
|
||||
time->d = dd;
|
||||
}
|
||||
|
||||
void timelib_do_normalize(timelib_time* time)
|
||||
{
|
||||
if (time->us != TIMELIB_UNSET) do_range_limit_fraction(&time->us, &time->s);
|
||||
if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->s, &time->i);
|
||||
if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->i, &time->h);
|
||||
if (time->s != TIMELIB_UNSET) do_range_limit(0, 24, 24, &time->h, &time->d);
|
||||
do_range_limit(1, 13, 12, &time->m, &time->y);
|
||||
|
||||
/* Short cut if we're doing things against the Epoch */
|
||||
if (time->y == 1970 && time->m == 1 && time->d != 1) {
|
||||
magic_date_calc(time);
|
||||
}
|
||||
|
||||
do {} while (do_range_limit_days(&time->y, &time->m, &time->d));
|
||||
do_range_limit(1, 13, 12, &time->m, &time->y);
|
||||
}
|
||||
@ -209,6 +256,8 @@ static void do_adjust_relative(timelib_time* time)
|
||||
timelib_do_normalize(time);
|
||||
|
||||
if (time->have_relative) {
|
||||
time->us += time->relative.us;
|
||||
|
||||
time->s += time->relative.s;
|
||||
time->i += time->relative.i;
|
||||
time->h += time->relative.h;
|
||||
@ -384,16 +433,15 @@ static timelib_sll do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
|
||||
case TIMELIB_ZONETYPE_OFFSET:
|
||||
|
||||
tz->is_localtime = 1;
|
||||
return tz->z * 60;
|
||||
return -tz->z;
|
||||
break;
|
||||
|
||||
case TIMELIB_ZONETYPE_ABBR: {
|
||||
timelib_sll tmp;
|
||||
|
||||
tz->is_localtime = 1;
|
||||
tmp = tz->z;
|
||||
tmp -= tz->dst * 60;
|
||||
tmp *= 60;
|
||||
tmp = -tz->z;
|
||||
tmp -= tz->dst * 3600;
|
||||
return tmp;
|
||||
}
|
||||
break;
|
||||
@ -407,19 +455,19 @@ static timelib_sll do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
|
||||
if (tzi) {
|
||||
timelib_time_offset *before, *after;
|
||||
timelib_sll tmp;
|
||||
int in_transistion;
|
||||
int in_transition;
|
||||
|
||||
tz->is_localtime = 1;
|
||||
before = timelib_get_time_zone_info(tz->sse, tzi);
|
||||
after = timelib_get_time_zone_info(tz->sse - before->offset, tzi);
|
||||
timelib_set_timezone(tz, tzi);
|
||||
|
||||
in_transistion = (
|
||||
((tz->sse - after->offset) >= (after->transistion_time + (before->offset - after->offset))) &&
|
||||
((tz->sse - after->offset) < after->transistion_time)
|
||||
in_transition = (
|
||||
((tz->sse - after->offset) >= (after->transition_time + (before->offset - after->offset))) &&
|
||||
((tz->sse - after->offset) < after->transition_time)
|
||||
);
|
||||
|
||||
if ((before->offset != after->offset) && !in_transistion) {
|
||||
if ((before->offset != after->offset) && !in_transition) {
|
||||
tmp = -after->offset;
|
||||
} else {
|
||||
tmp = -tz->z;
|
||||
|
@ -23,18 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "timelib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include "timelib_private.h"
|
||||
|
||||
static int month_tab_leap[12] = { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
|
||||
static int month_tab[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
|
||||
@ -60,7 +49,7 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts)
|
||||
if (ts >= 0) {
|
||||
tmp_days = days + 1;
|
||||
|
||||
if (tmp_days >= DAYS_PER_LYEAR_PERIOD || tmp_days <= -DAYS_PER_LYEAR_PERIOD) {
|
||||
if (tmp_days > DAYS_PER_LYEAR_PERIOD || tmp_days <= -DAYS_PER_LYEAR_PERIOD) {
|
||||
cur_year += YEARS_PER_LYEAR_PERIOD * (tmp_days / DAYS_PER_LYEAR_PERIOD);
|
||||
tmp_days -= DAYS_PER_LYEAR_PERIOD * (tmp_days / DAYS_PER_LYEAR_PERIOD);
|
||||
}
|
||||
@ -149,7 +138,7 @@ void timelib_update_from_sse(timelib_time *tm)
|
||||
switch (tm->zone_type) {
|
||||
case TIMELIB_ZONETYPE_ABBR:
|
||||
case TIMELIB_ZONETYPE_OFFSET: {
|
||||
timelib_unixtime2gmt(tm, tm->sse - (tm->z * 60) + (tm->dst * 3600));
|
||||
timelib_unixtime2gmt(tm, tm->sse + tm->z + (tm->dst * 3600));
|
||||
|
||||
goto cleanup;
|
||||
}
|
||||
@ -187,7 +176,7 @@ void timelib_unixtime2local(timelib_time *tm, timelib_sll ts)
|
||||
int z = tm->z;
|
||||
signed int dst = tm->dst;
|
||||
|
||||
timelib_unixtime2gmt(tm, ts - (tm->z * 60) + (tm->dst * 3600));
|
||||
timelib_unixtime2gmt(tm, ts + tm->z + (tm->dst * 3600));
|
||||
|
||||
tm->sse = ts;
|
||||
tm->z = z;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "php_date.h"
|
||||
#include "zend_interfaces.h"
|
||||
#include "lib/timelib.h"
|
||||
#include "lib/timelib_private.h"
|
||||
#include <time.h>
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
@ -923,6 +924,7 @@ PHP_MINFO_FUNCTION(date)
|
||||
static timelib_tzinfo *php_date_parse_tzfile(char *formal_tzname, const timelib_tzdb *tzdb)
|
||||
{
|
||||
timelib_tzinfo *tzi;
|
||||
int dummy_error_code;
|
||||
|
||||
if(!DATEG(tzcache)) {
|
||||
ALLOC_HASHTABLE(DATEG(tzcache));
|
||||
@ -933,14 +935,14 @@ static timelib_tzinfo *php_date_parse_tzfile(char *formal_tzname, const timelib_
|
||||
return tzi;
|
||||
}
|
||||
|
||||
tzi = timelib_parse_tzfile(formal_tzname, tzdb);
|
||||
tzi = timelib_parse_tzfile(formal_tzname, tzdb, &dummy_error_code);
|
||||
if (tzi) {
|
||||
zend_hash_str_add_ptr(DATEG(tzcache), formal_tzname, strlen(formal_tzname), tzi);
|
||||
}
|
||||
return tzi;
|
||||
}
|
||||
|
||||
timelib_tzinfo *php_date_parse_tzfile_wrapper(char *formal_tzname, const timelib_tzdb *tzdb)
|
||||
timelib_tzinfo *php_date_parse_tzfile_wrapper(char *formal_tzname, const timelib_tzdb *tzdb, int *dummy_error_code)
|
||||
{
|
||||
return php_date_parse_tzfile(formal_tzname, tzdb);
|
||||
}
|
||||
@ -1091,13 +1093,13 @@ static zend_string *date_format(char *format, size_t format_len, timelib_time *t
|
||||
if (localtime) {
|
||||
if (t->zone_type == TIMELIB_ZONETYPE_ABBR) {
|
||||
offset = timelib_time_offset_ctor();
|
||||
offset->offset = (t->z - (t->dst * 60)) * -60;
|
||||
offset->offset = (t->z + (t->dst * 3600));
|
||||
offset->leap_secs = 0;
|
||||
offset->is_dst = t->dst;
|
||||
offset->abbr = timelib_strdup(t->tz_abbr);
|
||||
} else if (t->zone_type == TIMELIB_ZONETYPE_OFFSET) {
|
||||
offset = timelib_time_offset_ctor();
|
||||
offset->offset = (t->z) * -60;
|
||||
offset->offset = (t->z);
|
||||
offset->leap_secs = 0;
|
||||
offset->is_dst = 0;
|
||||
offset->abbr = timelib_malloc(9); /* GMT±xxxx\0 */
|
||||
@ -1162,8 +1164,8 @@ static zend_string *date_format(char *format, size_t format_len, timelib_time *t
|
||||
case 'H': length = slprintf(buffer, 32, "%02d", (int) t->h); break;
|
||||
case 'i': length = slprintf(buffer, 32, "%02d", (int) t->i); break;
|
||||
case 's': length = slprintf(buffer, 32, "%02d", (int) t->s); break;
|
||||
case 'u': length = slprintf(buffer, 32, "%06d", (int) floor(t->f * 1000000 + 0.5)); break;
|
||||
case 'v': length = slprintf(buffer, 32, "%03d", (int) floor(t->f * 1000 + 0.5)); break;
|
||||
case 'u': length = slprintf(buffer, 32, "%06d", (int) floor(t->us)); break;
|
||||
case 'v': length = slprintf(buffer, 32, "%03d", (int) floor(t->us / 1000)); break;
|
||||
|
||||
/* timezone */
|
||||
case 'I': length = slprintf(buffer, 32, "%d", localtime ? offset->is_dst : 0); break;
|
||||
@ -1301,13 +1303,13 @@ PHPAPI int php_idate(char format, time_t ts, int localtime)
|
||||
if (!localtime) {
|
||||
if (t->zone_type == TIMELIB_ZONETYPE_ABBR) {
|
||||
offset = timelib_time_offset_ctor();
|
||||
offset->offset = (t->z - (t->dst * 60)) * -60;
|
||||
offset->offset = (t->z + (t->dst * 3600));
|
||||
offset->leap_secs = 0;
|
||||
offset->is_dst = t->dst;
|
||||
offset->abbr = timelib_strdup(t->tz_abbr);
|
||||
} else if (t->zone_type == TIMELIB_ZONETYPE_OFFSET) {
|
||||
offset = timelib_time_offset_ctor();
|
||||
offset->offset = (t->z - (t->dst * 60)) * -60;
|
||||
offset->offset = (t->z + (t->dst * 3600));
|
||||
offset->leap_secs = 0;
|
||||
offset->is_dst = t->dst;
|
||||
offset->abbr = timelib_malloc(9); /* GMT±xxxx\0 */
|
||||
@ -2255,9 +2257,9 @@ static HashTable *date_object_get_properties(zval *object) /* {{{ */
|
||||
timelib_sll utc_offset = dateobj->time->z;
|
||||
|
||||
ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d",
|
||||
utc_offset > 0 ? '-' : '+',
|
||||
abs(utc_offset / 60),
|
||||
abs((utc_offset % 60)));
|
||||
utc_offset < 0 ? '-' : '+',
|
||||
abs(utc_offset / 3600),
|
||||
abs(((utc_offset % 3600) / 60)));
|
||||
|
||||
ZVAL_NEW_STR(&zv, tmpstr);
|
||||
}
|
||||
@ -2347,9 +2349,9 @@ static HashTable *date_object_get_properties_timezone(zval *object) /* {{{ */
|
||||
zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0);
|
||||
|
||||
ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d",
|
||||
tzobj->tzi.utc_offset > 0 ? '-' : '+',
|
||||
abs(tzobj->tzi.utc_offset / 60),
|
||||
abs((tzobj->tzi.utc_offset % 60)));
|
||||
tzobj->tzi.utc_offset < 0 ? '-' : '+',
|
||||
abs(tzobj->tzi.utc_offset / 3600),
|
||||
abs(((tzobj->tzi.utc_offset % 3600) / 60)));
|
||||
|
||||
ZVAL_NEW_STR(&zv, tmpstr);
|
||||
}
|
||||
@ -2946,10 +2948,10 @@ void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time *
|
||||
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(minute, i);
|
||||
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(second, s);
|
||||
|
||||
if (parsed_time->f == -99999) {
|
||||
if (parsed_time->us == -99999) {
|
||||
add_assoc_bool(return_value, "fraction", 0);
|
||||
} else {
|
||||
add_assoc_double(return_value, "fraction", parsed_time->f);
|
||||
add_assoc_double(return_value, "fraction", (double)parsed_time->us / 1000000.0);
|
||||
}
|
||||
|
||||
zval_from_error_container(return_value, error);
|
||||
@ -3398,10 +3400,10 @@ PHP_FUNCTION(date_offset_get)
|
||||
timelib_time_offset_dtor(offset);
|
||||
break;
|
||||
case TIMELIB_ZONETYPE_OFFSET:
|
||||
RETVAL_LONG(dateobj->time->z * -60);
|
||||
RETVAL_LONG(dateobj->time->z);
|
||||
break;
|
||||
case TIMELIB_ZONETYPE_ABBR:
|
||||
RETVAL_LONG((dateobj->time->z - (60 * dateobj->time->dst)) * -60);
|
||||
RETVAL_LONG((dateobj->time->z + (3600 * dateobj->time->dst)));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
@ -3815,9 +3817,9 @@ PHP_FUNCTION(timezone_name_get)
|
||||
timelib_sll utc_offset = tzobj->tzi.utc_offset;
|
||||
|
||||
ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d",
|
||||
utc_offset > 0 ? '-' : '+',
|
||||
abs(utc_offset / 60),
|
||||
abs((utc_offset % 60)));
|
||||
utc_offset < 0 ? '-' : '+',
|
||||
abs(utc_offset / 3600),
|
||||
abs(((utc_offset % 3600) / 60)));
|
||||
|
||||
RETURN_NEW_STR(tmpstr);
|
||||
}
|
||||
@ -3878,10 +3880,10 @@ PHP_FUNCTION(timezone_offset_get)
|
||||
timelib_time_offset_dtor(offset);
|
||||
break;
|
||||
case TIMELIB_ZONETYPE_OFFSET:
|
||||
RETURN_LONG(tzobj->tzi.utc_offset * -60);
|
||||
RETURN_LONG(tzobj->tzi.utc_offset);
|
||||
break;
|
||||
case TIMELIB_ZONETYPE_ABBR:
|
||||
RETURN_LONG((tzobj->tzi.z.utc_offset - (tzobj->tzi.z.dst*60)) * -60);
|
||||
RETURN_LONG(tzobj->tzi.z.utc_offset + (tzobj->tzi.z.dst * 3600));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -8,17 +8,8 @@ date_default_timezone_set('UTC');
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(6) {
|
||||
array(5) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(0)
|
||||
["timezone_id"]=>
|
||||
string(16) "Antarctica/Troll"
|
||||
}
|
||||
[1]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
@ -27,7 +18,7 @@ array(6) {
|
||||
["timezone_id"]=>
|
||||
string(13) "Etc/Universal"
|
||||
}
|
||||
[2]=>
|
||||
[1]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
@ -36,7 +27,7 @@ array(6) {
|
||||
["timezone_id"]=>
|
||||
string(7) "Etc/UTC"
|
||||
}
|
||||
[3]=>
|
||||
[2]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
@ -45,6 +36,15 @@ array(6) {
|
||||
["timezone_id"]=>
|
||||
string(8) "Etc/Zulu"
|
||||
}
|
||||
[3]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(0)
|
||||
["timezone_id"]=>
|
||||
string(3) "UTC"
|
||||
}
|
||||
[4]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
@ -54,14 +54,5 @@ array(6) {
|
||||
["timezone_id"]=>
|
||||
string(3) "UTC"
|
||||
}
|
||||
[5]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(0)
|
||||
["timezone_id"]=>
|
||||
string(3) "UTC"
|
||||
}
|
||||
}
|
||||
Done
|
||||
|
@ -53,30 +53,9 @@ Array
|
||||
[comments] => %s
|
||||
)
|
||||
Array
|
||||
(
|
||||
[country_code] => %s
|
||||
[latitude] => %f
|
||||
[longitude] => %f
|
||||
[comments] =>
|
||||
)
|
||||
Array
|
||||
(
|
||||
[country_code] => %s
|
||||
[latitude] => %f
|
||||
[longitude] => %f
|
||||
[comments] => %s
|
||||
)
|
||||
Array
|
||||
(
|
||||
[country_code] => %s
|
||||
[latitude] => %f
|
||||
[longitude] => %f
|
||||
[comments] => %s
|
||||
)
|
||||
Array
|
||||
(
|
||||
[country_code] => %s
|
||||
[latitude] => %f
|
||||
[longitude] => %f
|
||||
[comments] =>
|
||||
)
|
||||
|
@ -29,15 +29,15 @@ string(5) "array"
|
||||
int(%d)
|
||||
|
||||
-- Format a sample entry --
|
||||
array(11) {
|
||||
array(12) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(true)
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(-14400)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(18) "America/Porto_Acre"
|
||||
string(18) "Australia/Adelaide"
|
||||
}
|
||||
[1]=>
|
||||
array(3) {
|
||||
@ -51,47 +51,47 @@ array(11) {
|
||||
[2]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(true)
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(-14400)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(16) "America/Eirunepe"
|
||||
string(21) "Australia/Broken_Hill"
|
||||
}
|
||||
[3]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(true)
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(-14400)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(18) "America/Rio_Branco"
|
||||
string(16) "Australia/Darwin"
|
||||
}
|
||||
[4]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(true)
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(-14400)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(11) "Brazil/Acre"
|
||||
string(15) "Australia/North"
|
||||
}
|
||||
[5]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(13) "Asia/Jayapura"
|
||||
string(15) "Australia/South"
|
||||
}
|
||||
[6]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(21) "Australia/Broken_Hill"
|
||||
string(20) "Australia/Yancowinna"
|
||||
}
|
||||
[7]=>
|
||||
array(3) {
|
||||
@ -100,7 +100,7 @@ array(11) {
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
["timezone_id"]=>
|
||||
string(16) "Australia/Darwin"
|
||||
string(21) "Australia/Broken_Hill"
|
||||
}
|
||||
[8]=>
|
||||
array(3) {
|
||||
@ -109,7 +109,7 @@ array(11) {
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
["timezone_id"]=>
|
||||
string(15) "Australia/North"
|
||||
string(16) "Australia/Darwin"
|
||||
}
|
||||
[9]=>
|
||||
array(3) {
|
||||
@ -118,9 +118,18 @@ array(11) {
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
["timezone_id"]=>
|
||||
string(15) "Australia/South"
|
||||
string(15) "Australia/North"
|
||||
}
|
||||
[10]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
["timezone_id"]=>
|
||||
string(15) "Australia/South"
|
||||
}
|
||||
[11]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
|
@ -42,7 +42,7 @@ array(16) {
|
||||
["zone_type"]=>
|
||||
int(2)
|
||||
["zone"]=>
|
||||
int(-60)
|
||||
int(3600)
|
||||
["is_dst"]=>
|
||||
bool(false)
|
||||
["tz_abbr"]=>
|
||||
|
@ -40,20 +40,20 @@ echo "\n";
|
||||
NULL
|
||||
NULL
|
||||
|
||||
int(-60)
|
||||
int(3600)
|
||||
string(1) "A"
|
||||
|
||||
int(-60)
|
||||
int(3600)
|
||||
string(1) "A"
|
||||
|
||||
int(-60)
|
||||
int(3600)
|
||||
string(1) "A"
|
||||
|
||||
int(-60)
|
||||
int(3600)
|
||||
string(1) "A"
|
||||
|
||||
int(-60)
|
||||
int(3600)
|
||||
string(1) "A"
|
||||
|
||||
int(-60)
|
||||
int(3600)
|
||||
string(1) "A"
|
||||
|
@ -5,7 +5,7 @@ date.timezone=Asia/Singapore
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
print strtotime('2008-05-23 00:00:00 SGT');
|
||||
print strtotime('2008-05-23 00:00:00 +08');
|
||||
print "\n";
|
||||
print strtotime('2008-05-23 00:00:00');
|
||||
|
||||
|
@ -7,10 +7,10 @@ date_default_timezone_set('UTC');
|
||||
$earlyDate1 = DateTime::createFromFormat('U.u', '1.8642')->modify('-5 seconds');
|
||||
$earlyDate2 = DateTime::createFromFormat('U.u', '1.2768')->modify('-5 seconds');
|
||||
$earlyDate3 = DateTime::createFromFormat('U.u', '1.2768')->modify('-5 seconds');
|
||||
|
||||
// var_dump($earlyDate1, $earlyDate2, $earlyDate3);
|
||||
var_dump($earlyDate1 == $earlyDate2);
|
||||
var_dump($earlyDate1 < $earlyDate2);
|
||||
var_dump($earlyDate2 > $earlyDate1);
|
||||
var_dump($earlyDate1 > $earlyDate2);
|
||||
var_dump($earlyDate2 < $earlyDate1);
|
||||
var_dump($earlyDate2 == $earlyDate3);
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
|
@ -104,7 +104,7 @@ array(15) {
|
||||
["zone_type"]=>
|
||||
int(1)
|
||||
["zone"]=>
|
||||
int(720)
|
||||
int(-43200)
|
||||
["is_dst"]=>
|
||||
bool(false)
|
||||
}
|
||||
@ -228,7 +228,7 @@ array(15) {
|
||||
["zone_type"]=>
|
||||
int(1)
|
||||
["zone"]=>
|
||||
int(180)
|
||||
int(-10800)
|
||||
["is_dst"]=>
|
||||
bool(false)
|
||||
}
|
||||
|
@ -10,22 +10,22 @@ echo "Done\n";
|
||||
--EXPECTF--
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165897782)
|
||||
int(1165897761)
|
||||
["sunset"]=>
|
||||
int(1165934168)
|
||||
int(1165934160)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165896176)
|
||||
int(1165896156)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165935773)
|
||||
int(1165935765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165894353)
|
||||
int(1165894334)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165937597)
|
||||
int(1165937588)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165892570)
|
||||
int(1165892551)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165939380)
|
||||
int(1165939371)
|
||||
}
|
||||
Done
|
||||
|
@ -11,13 +11,13 @@ foreach ($sun_info as $key => $elem )
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
2007-04-13 06:12:19 CEST sunrise
|
||||
2007-04-13 20:31:50 CEST sunset
|
||||
2007-04-13 13:22:05 CEST transit
|
||||
2007-04-13 05:28:03 CEST civil_twilight_begin
|
||||
2007-04-13 21:16:06 CEST civil_twilight_end
|
||||
2007-04-13 04:30:08 CEST nautical_twilight_begin
|
||||
2007-04-13 22:14:01 CEST nautical_twilight_end
|
||||
2007-04-13 03:14:36 CEST astronomical_twilight_begin
|
||||
2007-04-13 23:29:33 CEST astronomical_twilight_end
|
||||
2007-04-13 06:13:31 CEST sunrise
|
||||
2007-04-13 20:30:51 CEST sunset
|
||||
2007-04-13 13:22:11 CEST transit
|
||||
2007-04-13 05:29:22 CEST civil_twilight_begin
|
||||
2007-04-13 21:15:00 CEST civil_twilight_end
|
||||
2007-04-13 04:31:43 CEST nautical_twilight_begin
|
||||
2007-04-13 22:12:39 CEST nautical_twilight_end
|
||||
2007-04-13 03:17:01 CEST astronomical_twilight_begin
|
||||
2007-04-13 23:27:21 CEST astronomical_twilight_end
|
||||
Done
|
||||
|
@ -84,331 +84,331 @@ foreach($inputs as $input) {
|
||||
-- Iteration 1 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 3 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 4 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(-69665)
|
||||
int(-69672)
|
||||
["sunset"]=>
|
||||
int(-33260)
|
||||
int(-33281)
|
||||
["transit"]=>
|
||||
int(-51462)
|
||||
int(-51476)
|
||||
["civil_twilight_begin"]=>
|
||||
int(-71269)
|
||||
int(-71277)
|
||||
["civil_twilight_end"]=>
|
||||
int(-31655)
|
||||
int(-31675)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(-73092)
|
||||
int(-73100)
|
||||
["nautical_twilight_end"]=>
|
||||
int(-29832)
|
||||
int(-29852)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(-74874)
|
||||
int(-74883)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(-28050)
|
||||
int(-28069)
|
||||
}
|
||||
|
||||
-- Iteration 5 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 6 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(-69665)
|
||||
int(-69672)
|
||||
["sunset"]=>
|
||||
int(-33260)
|
||||
int(-33281)
|
||||
["transit"]=>
|
||||
int(-51462)
|
||||
int(-51476)
|
||||
["civil_twilight_begin"]=>
|
||||
int(-71269)
|
||||
int(-71277)
|
||||
["civil_twilight_end"]=>
|
||||
int(-31655)
|
||||
int(-31675)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(-73092)
|
||||
int(-73100)
|
||||
["nautical_twilight_end"]=>
|
||||
int(-29832)
|
||||
int(-29852)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(-74874)
|
||||
int(-74883)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(-28050)
|
||||
int(-28069)
|
||||
}
|
||||
|
||||
-- Iteration 7 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1226363)
|
||||
int(1226368)
|
||||
["sunset"]=>
|
||||
int(1263468)
|
||||
int(1263442)
|
||||
["transit"]=>
|
||||
int(1244916)
|
||||
int(1244905)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1224788)
|
||||
int(1224792)
|
||||
["civil_twilight_end"]=>
|
||||
int(1265044)
|
||||
int(1265019)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1222993)
|
||||
int(1222996)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1266839)
|
||||
int(1266815)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1221233)
|
||||
int(1221234)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1268599)
|
||||
int(1268576)
|
||||
}
|
||||
|
||||
-- Iteration 8 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 9 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 10 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 11 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 12 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 13 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 14 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 15 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 16 --
|
||||
@ -444,49 +444,49 @@ bool(false)
|
||||
-- Iteration 22 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 23 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(16748)
|
||||
int(16742)
|
||||
["sunset"]=>
|
||||
int(53182)
|
||||
int(53161)
|
||||
["transit"]=>
|
||||
int(34965)
|
||||
int(34951)
|
||||
["civil_twilight_begin"]=>
|
||||
int(15145)
|
||||
int(15138)
|
||||
["civil_twilight_end"]=>
|
||||
int(54786)
|
||||
int(54765)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(13324)
|
||||
int(13316)
|
||||
["nautical_twilight_end"]=>
|
||||
int(56607)
|
||||
int(56587)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(11542)
|
||||
int(11534)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(58389)
|
||||
int(58369)
|
||||
}
|
||||
|
||||
-- Iteration 24 --
|
||||
|
||||
Warning: date_sun_info() expects parameter 1 to be integer, resource given in %s on line %d
|
||||
bool(false)
|
||||
===Done===
|
||||
===Done===
|
||||
|
@ -84,45 +84,45 @@ foreach($inputs as $input) {
|
||||
-- Iteration 1 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894152)
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937798)
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892809)
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939141)
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891239)
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940710)
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889663)
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942287)
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894254)
|
||||
int(1165894240)
|
||||
["sunset"]=>
|
||||
int(1165937695)
|
||||
int(1165937681)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892911)
|
||||
int(1165892898)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939038)
|
||||
int(1165939024)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891344)
|
||||
int(1165891330)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940606)
|
||||
int(1165940591)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889771)
|
||||
int(1165889758)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942179)
|
||||
int(1165942164)
|
||||
}
|
||||
|
||||
-- Iteration 3 --
|
||||
@ -132,283 +132,283 @@ array(9) {
|
||||
["sunset"]=>
|
||||
bool(true)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
bool(true)
|
||||
["civil_twilight_end"]=>
|
||||
bool(true)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165883331)
|
||||
int(1165883368)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165948619)
|
||||
int(1165948554)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165890260)
|
||||
int(1165890281)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165941690)
|
||||
int(1165941641)
|
||||
}
|
||||
|
||||
-- Iteration 4 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894085)
|
||||
int(1165894072)
|
||||
["sunset"]=>
|
||||
int(1165937865)
|
||||
int(1165937850)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165895431)
|
||||
int(1165895418)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165936519)
|
||||
int(1165936504)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165896998)
|
||||
int(1165896984)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165934952)
|
||||
int(1165934938)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165898564)
|
||||
int(1165898549)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165933386)
|
||||
int(1165933372)
|
||||
}
|
||||
|
||||
-- Iteration 5 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165895237)
|
||||
int(1165895221)
|
||||
["sunset"]=>
|
||||
int(1165936713)
|
||||
int(1165936701)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165893873)
|
||||
int(1165893858)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165938077)
|
||||
int(1165938064)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165892293)
|
||||
int(1165892278)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165939656)
|
||||
int(1165939643)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165890721)
|
||||
int(1165890706)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165941229)
|
||||
int(1165941215)
|
||||
}
|
||||
|
||||
-- Iteration 6 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165893058)
|
||||
int(1165893046)
|
||||
["sunset"]=>
|
||||
int(1165938891)
|
||||
int(1165938875)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165891680)
|
||||
int(1165891669)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165940269)
|
||||
int(1165940253)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165890055)
|
||||
int(1165890044)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165941895)
|
||||
int(1165941878)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165888402)
|
||||
int(1165888392)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165943548)
|
||||
int(1165943530)
|
||||
}
|
||||
|
||||
-- Iteration 7 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894152)
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937798)
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892809)
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939141)
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891239)
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940710)
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889663)
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942287)
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 8 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894152)
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937798)
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892809)
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939141)
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891239)
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940710)
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889663)
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942287)
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 9 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894203)
|
||||
int(1165894189)
|
||||
["sunset"]=>
|
||||
int(1165937747)
|
||||
int(1165937733)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892860)
|
||||
int(1165892846)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939090)
|
||||
int(1165939075)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891292)
|
||||
int(1165891278)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940658)
|
||||
int(1165940643)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889717)
|
||||
int(1165889704)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942233)
|
||||
int(1165942217)
|
||||
}
|
||||
|
||||
-- Iteration 10 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894152)
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937798)
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892809)
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939141)
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891239)
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940710)
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889663)
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942287)
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 11 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894152)
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937798)
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892809)
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939141)
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891239)
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940710)
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889663)
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942287)
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 12 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894254)
|
||||
int(1165894240)
|
||||
["sunset"]=>
|
||||
int(1165937695)
|
||||
int(1165937681)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892911)
|
||||
int(1165892898)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939038)
|
||||
int(1165939024)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891344)
|
||||
int(1165891330)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940606)
|
||||
int(1165940591)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889771)
|
||||
int(1165889758)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942179)
|
||||
int(1165942164)
|
||||
}
|
||||
|
||||
-- Iteration 13 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894152)
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937798)
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892809)
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939141)
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891239)
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940710)
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889663)
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942287)
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 14 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894254)
|
||||
int(1165894240)
|
||||
["sunset"]=>
|
||||
int(1165937695)
|
||||
int(1165937681)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892911)
|
||||
int(1165892898)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939038)
|
||||
int(1165939024)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891344)
|
||||
int(1165891330)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940606)
|
||||
int(1165940591)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889771)
|
||||
int(1165889758)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942179)
|
||||
int(1165942164)
|
||||
}
|
||||
|
||||
-- Iteration 15 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894152)
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937798)
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892809)
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939141)
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891239)
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940710)
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889663)
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942287)
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 16 --
|
||||
@ -444,45 +444,45 @@ bool(false)
|
||||
-- Iteration 22 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894152)
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937798)
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892809)
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939141)
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891239)
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940710)
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889663)
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942287)
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 23 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165894152)
|
||||
int(1165894138)
|
||||
["sunset"]=>
|
||||
int(1165937798)
|
||||
int(1165937784)
|
||||
["transit"]=>
|
||||
int(1165915975)
|
||||
int(1165915961)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165892809)
|
||||
int(1165892795)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165939141)
|
||||
int(1165939127)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165891239)
|
||||
int(1165891226)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165940710)
|
||||
int(1165940696)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165889663)
|
||||
int(1165889650)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165942287)
|
||||
int(1165942271)
|
||||
}
|
||||
|
||||
-- Iteration 24 --
|
||||
|
@ -85,331 +85,331 @@ foreach($inputs as $input) {
|
||||
-- Iteration 1 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906242)
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942625)
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924434)
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904636)
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944231)
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902813)
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946054)
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901030)
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947838)
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906002)
|
||||
int(1165905981)
|
||||
["sunset"]=>
|
||||
int(1165942385)
|
||||
int(1165942378)
|
||||
["transit"]=>
|
||||
int(1165924194)
|
||||
int(1165924179)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904396)
|
||||
int(1165904376)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165943991)
|
||||
int(1165943983)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902573)
|
||||
int(1165902553)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165945814)
|
||||
int(1165945806)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165900789)
|
||||
int(1165900771)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947598)
|
||||
int(1165947588)
|
||||
}
|
||||
|
||||
-- Iteration 3 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165879335)
|
||||
int(1165879309)
|
||||
["sunset"]=>
|
||||
int(1165917916)
|
||||
int(1165917937)
|
||||
["transit"]=>
|
||||
int(1165898625)
|
||||
int(1165898623)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165877811)
|
||||
int(1165877787)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165919440)
|
||||
int(1165919460)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165876064)
|
||||
int(1165876041)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165921187)
|
||||
int(1165921205)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165874341)
|
||||
int(1165874319)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165922910)
|
||||
int(1165922928)
|
||||
}
|
||||
|
||||
-- Iteration 4 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165864483)
|
||||
int(1165864467)
|
||||
["sunset"]=>
|
||||
int(1165900762)
|
||||
int(1165900749)
|
||||
["transit"]=>
|
||||
int(1165882623)
|
||||
int(1165882608)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165862873)
|
||||
int(1165862856)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165902372)
|
||||
int(1165902359)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165861045)
|
||||
int(1165861029)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165904200)
|
||||
int(1165904187)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165859259)
|
||||
int(1165859242)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165905987)
|
||||
int(1165905973)
|
||||
}
|
||||
|
||||
-- Iteration 5 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165903721)
|
||||
int(1165903700)
|
||||
["sunset"]=>
|
||||
int(1165940105)
|
||||
int(1165940097)
|
||||
["transit"]=>
|
||||
int(1165921913)
|
||||
int(1165921899)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165902115)
|
||||
int(1165902095)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165941711)
|
||||
int(1165941702)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165900292)
|
||||
int(1165900272)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165943534)
|
||||
int(1165943525)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165898508)
|
||||
int(1165898490)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165945317)
|
||||
int(1165945308)
|
||||
}
|
||||
|
||||
-- Iteration 6 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165908763)
|
||||
int(1165908743)
|
||||
["sunset"]=>
|
||||
int(1165945146)
|
||||
int(1165945138)
|
||||
["transit"]=>
|
||||
int(1165926954)
|
||||
int(1165926940)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165907157)
|
||||
int(1165907137)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165946752)
|
||||
int(1165946743)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165905334)
|
||||
int(1165905315)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165948575)
|
||||
int(1165948566)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165903551)
|
||||
int(1165903532)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165950358)
|
||||
int(1165950349)
|
||||
}
|
||||
|
||||
-- Iteration 7 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165919856)
|
||||
int(1165920008)
|
||||
["sunset"]=>
|
||||
int(1165969985)
|
||||
int(1165970177)
|
||||
["transit"]=>
|
||||
int(1165944920)
|
||||
int(1165945092)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165918203)
|
||||
int(1165918353)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165971638)
|
||||
int(1165971832)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165916223)
|
||||
int(1165916371)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165973617)
|
||||
int(1165973814)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165914116)
|
||||
int(1165914258)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165975725)
|
||||
int(1165975927)
|
||||
}
|
||||
|
||||
-- Iteration 8 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906242)
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942625)
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924434)
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904636)
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944231)
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902813)
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946054)
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901030)
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947838)
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 9 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906122)
|
||||
int(1165906101)
|
||||
["sunset"]=>
|
||||
int(1165942505)
|
||||
int(1165942498)
|
||||
["transit"]=>
|
||||
int(1165924314)
|
||||
int(1165924300)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904516)
|
||||
int(1165904496)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944111)
|
||||
int(1165944103)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902693)
|
||||
int(1165902673)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165945934)
|
||||
int(1165945926)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165900910)
|
||||
int(1165900891)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947718)
|
||||
int(1165947708)
|
||||
}
|
||||
|
||||
-- Iteration 10 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906242)
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942625)
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924434)
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904636)
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944231)
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902813)
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946054)
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901030)
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947838)
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 11 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906242)
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942625)
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924434)
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904636)
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944231)
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902813)
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946054)
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901030)
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947838)
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 12 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906002)
|
||||
int(1165905981)
|
||||
["sunset"]=>
|
||||
int(1165942385)
|
||||
int(1165942378)
|
||||
["transit"]=>
|
||||
int(1165924194)
|
||||
int(1165924179)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904396)
|
||||
int(1165904376)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165943991)
|
||||
int(1165943983)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902573)
|
||||
int(1165902553)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165945814)
|
||||
int(1165945806)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165900789)
|
||||
int(1165900771)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947598)
|
||||
int(1165947588)
|
||||
}
|
||||
|
||||
-- Iteration 13 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906242)
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942625)
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924434)
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904636)
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944231)
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902813)
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946054)
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901030)
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947838)
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 14 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906002)
|
||||
int(1165905981)
|
||||
["sunset"]=>
|
||||
int(1165942385)
|
||||
int(1165942378)
|
||||
["transit"]=>
|
||||
int(1165924194)
|
||||
int(1165924179)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904396)
|
||||
int(1165904376)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165943991)
|
||||
int(1165943983)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902573)
|
||||
int(1165902553)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165945814)
|
||||
int(1165945806)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165900789)
|
||||
int(1165900771)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947598)
|
||||
int(1165947588)
|
||||
}
|
||||
|
||||
-- Iteration 15 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906242)
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942625)
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924434)
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904636)
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944231)
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902813)
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946054)
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901030)
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947838)
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 16 --
|
||||
@ -445,45 +445,45 @@ bool(false)
|
||||
-- Iteration 22 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906242)
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942625)
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924434)
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904636)
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944231)
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902813)
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946054)
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901030)
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947838)
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 23 --
|
||||
array(9) {
|
||||
["sunrise"]=>
|
||||
int(1165906242)
|
||||
int(1165906221)
|
||||
["sunset"]=>
|
||||
int(1165942625)
|
||||
int(1165942618)
|
||||
["transit"]=>
|
||||
int(1165924434)
|
||||
int(1165924420)
|
||||
["civil_twilight_begin"]=>
|
||||
int(1165904636)
|
||||
int(1165904616)
|
||||
["civil_twilight_end"]=>
|
||||
int(1165944231)
|
||||
int(1165944223)
|
||||
["nautical_twilight_begin"]=>
|
||||
int(1165902813)
|
||||
int(1165902793)
|
||||
["nautical_twilight_end"]=>
|
||||
int(1165946054)
|
||||
int(1165946046)
|
||||
["astronomical_twilight_begin"]=>
|
||||
int(1165901030)
|
||||
int(1165901011)
|
||||
["astronomical_twilight_end"]=>
|
||||
int(1165947838)
|
||||
int(1165947828)
|
||||
}
|
||||
|
||||
-- Iteration 24 --
|
||||
|
@ -109,38 +109,38 @@ foreach($inputs as $key =>$value) {
|
||||
|
||||
--int 0--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--int 1--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--int 12345--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--int -12345--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--float 10.5--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--float -10.5--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--float .5--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--empty array--
|
||||
|
||||
@ -188,33 +188,33 @@ bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
@ -306,11 +306,11 @@ bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
|
||||
--unset var--
|
||||
string(5) "08:56"
|
||||
float(8.944%d)
|
||||
int(28599)
|
||||
float(8.943%d)
|
||||
int(28596)
|
||||
===DONE===
|
||||
|
@ -103,12 +103,12 @@ foreach($inputs as $key =>$value) {
|
||||
--int 0--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177627)
|
||||
int(1218177629)
|
||||
|
||||
--int 1--
|
||||
string(5) "01:09"
|
||||
float(1.155%d)
|
||||
int(1218177558)
|
||||
int(1218177560)
|
||||
|
||||
--int 12345--
|
||||
bool(false)
|
||||
@ -167,32 +167,32 @@ bool(false)
|
||||
--uppercase NULL--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177627)
|
||||
int(1218177629)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177627)
|
||||
int(1218177629)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "01:09"
|
||||
float(1.155%d)
|
||||
int(1218177558)
|
||||
int(1218177560)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177627)
|
||||
int(1218177629)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "01:09"
|
||||
float(1.155%d)
|
||||
int(1218177558)
|
||||
int(1218177560)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177627)
|
||||
int(1218177629)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
@ -285,10 +285,10 @@ bool(false)
|
||||
--undefined var--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177627)
|
||||
int(1218177629)
|
||||
|
||||
--unset var--
|
||||
string(5) "01:10"
|
||||
float(1.174%d)
|
||||
int(1218177627)
|
||||
int(1218177629)
|
||||
===DONE===
|
||||
|
@ -103,24 +103,24 @@ foreach($inputs as $key =>$value) {
|
||||
*** Testing date_sunrise() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "05:12"
|
||||
float(5.200%d)
|
||||
int(1218172321)
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--int 1--
|
||||
string(5) "05:08"
|
||||
float(5.133%d)
|
||||
int(1218172081)
|
||||
string(5) "05:07"
|
||||
float(5.129%d)
|
||||
int(1218172067)
|
||||
|
||||
--int 12345--
|
||||
string(5) "21:45"
|
||||
float(21.759%d)
|
||||
int(1218145534)
|
||||
float(21.757%d)
|
||||
int(1218145525)
|
||||
|
||||
--int -12345--
|
||||
string(5) "12:41"
|
||||
float(12.698%d)
|
||||
int(1218199315)
|
||||
float(12.694%d)
|
||||
int(1218199301)
|
||||
|
||||
--empty array--
|
||||
|
||||
@ -167,34 +167,34 @@ Warning: date_sunrise() expects parameter 4 to be float, array given in %s on li
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "05:12"
|
||||
float(5.200%d)
|
||||
int(1218172321)
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "05:12"
|
||||
float(5.200%d)
|
||||
int(1218172321)
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "05:08"
|
||||
float(5.133%d)
|
||||
int(1218172081)
|
||||
string(5) "05:07"
|
||||
float(5.129%d)
|
||||
int(1218172067)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "05:12"
|
||||
float(5.200%d)
|
||||
int(1218172321)
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "05:08"
|
||||
float(5.133%d)
|
||||
int(1218172081)
|
||||
string(5) "05:07"
|
||||
float(5.129%d)
|
||||
int(1218172067)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "05:12"
|
||||
float(5.200%d)
|
||||
int(1218172321)
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
@ -285,12 +285,12 @@ Warning: date_sunrise() expects parameter 4 to be float, object given in %s on l
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "05:12"
|
||||
float(5.200%d)
|
||||
int(1218172321)
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
|
||||
--unset var--
|
||||
string(5) "05:12"
|
||||
float(5.200%d)
|
||||
int(1218172321)
|
||||
string(5) "05:11"
|
||||
float(5.196%d)
|
||||
int(1218172307)
|
||||
===DONE===
|
||||
|
@ -113,14 +113,14 @@ bool(false)
|
||||
bool(false)
|
||||
|
||||
--int 12345--
|
||||
string(5) "09:51"
|
||||
float(9.855%d)
|
||||
int(1218169278)
|
||||
string(5) "09:50"
|
||||
float(9.849%d)
|
||||
int(1218169259)
|
||||
|
||||
--int -12345--
|
||||
string(5) "09:54"
|
||||
float(9.9097820911118)
|
||||
int(1218169475)
|
||||
float(9.904%d)
|
||||
int(1218169455)
|
||||
|
||||
--empty array--
|
||||
|
||||
|
@ -102,24 +102,24 @@ foreach($inputs as $key =>$value) {
|
||||
*** Testing date_sunrise() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "05:48"
|
||||
float(5.800%d)
|
||||
int(1218174483)
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--int 1--
|
||||
string(5) "06:48"
|
||||
float(6.800%d)
|
||||
int(1218174483)
|
||||
string(5) "06:47"
|
||||
float(6.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--int 12345--
|
||||
string(5) "14:48"
|
||||
float(14.800%d)
|
||||
int(1218174483)
|
||||
string(5) "14:47"
|
||||
float(14.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--int -12345--
|
||||
string(5) "12:48"
|
||||
float(12.800%d)
|
||||
int(1218174483)
|
||||
string(5) "12:47"
|
||||
float(12.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--empty array--
|
||||
|
||||
@ -166,34 +166,34 @@ Warning: date_sunrise() expects parameter 6 to be float, array given in %s on li
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "05:48"
|
||||
float(5.800%d)
|
||||
int(1218174483)
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "05:48"
|
||||
float(5.800%d)
|
||||
int(1218174483)
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "06:48"
|
||||
float(6.800%d)
|
||||
int(1218174483)
|
||||
string(5) "06:47"
|
||||
float(6.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "05:48"
|
||||
float(5.800%d)
|
||||
int(1218174483)
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "06:48"
|
||||
float(6.800%d)
|
||||
int(1218174483)
|
||||
string(5) "06:47"
|
||||
float(6.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "05:48"
|
||||
float(5.800%d)
|
||||
int(1218174483)
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
@ -284,12 +284,12 @@ Warning: date_sunrise() expects parameter 6 to be float, object given in %s on l
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "05:48"
|
||||
float(5.800%d)
|
||||
int(1218174483)
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
|
||||
--unset var--
|
||||
string(5) "05:48"
|
||||
float(5.800%d)
|
||||
int(1218174483)
|
||||
string(5) "05:47"
|
||||
float(5.796%d)
|
||||
int(1218174468)
|
||||
===DONE===
|
||||
|
@ -36,15 +36,15 @@ foreach($inputs as $timezone => $value) {
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing date_sunrise() : usage variation ***
|
||||
string(5) "06:42"
|
||||
string(5) "06:41"
|
||||
string(5) "06:41"
|
||||
string(5) "05:07"
|
||||
string(5) "05:09"
|
||||
string(5) "05:11"
|
||||
string(5) "05:58"
|
||||
string(5) "05:59"
|
||||
string(5) "06:00"
|
||||
string(5) "07:31"
|
||||
string(5) "07:30"
|
||||
string(5) "07:29"
|
||||
string(5) "05:53"
|
||||
string(5) "05:52"
|
||||
string(5) "05:53"
|
||||
string(5) "05:59"
|
||||
string(5) "06:01"
|
||||
|
@ -109,38 +109,38 @@ foreach($inputs as $key =>$value) {
|
||||
|
||||
--int 0--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--int 1--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--int 12345--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--int -12345--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--float 10.5--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--float -10.5--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--float .5--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--empty array--
|
||||
|
||||
@ -188,33 +188,33 @@ bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
@ -306,11 +306,11 @@ bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
|
||||
--unset var--
|
||||
string(5) "18:22"
|
||||
float(18.377%d)
|
||||
int(62558)
|
||||
float(18.373%d)
|
||||
int(62545)
|
||||
===DONE===
|
||||
|
@ -105,13 +105,13 @@ foreach($inputs as $key =>$value) {
|
||||
|
||||
--int 0--
|
||||
string(5) "17:43"
|
||||
float(17.730%d)
|
||||
int(1218197630)
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--int 1--
|
||||
string(5) "17:44"
|
||||
float(17.749%d)
|
||||
int(1218197698)
|
||||
string(5) "17:45"
|
||||
float(17.750%d)
|
||||
int(1218197701)
|
||||
|
||||
--int 12345--
|
||||
bool(false)
|
||||
@ -169,33 +169,33 @@ bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "17:43"
|
||||
float(17.730%d)
|
||||
int(1218197630)
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "17:43"
|
||||
float(17.730%d)
|
||||
int(1218197630)
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "17:44"
|
||||
float(17.749%d)
|
||||
int(1218197698)
|
||||
string(5) "17:45"
|
||||
float(17.750%d)
|
||||
int(1218197701)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "17:43"
|
||||
float(17.730%d)
|
||||
int(1218197630)
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "17:44"
|
||||
float(17.749%d)
|
||||
int(1218197698)
|
||||
string(5) "17:45"
|
||||
float(17.750%d)
|
||||
int(1218197701)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "17:43"
|
||||
float(17.730%d)
|
||||
int(1218197630)
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
@ -287,11 +287,11 @@ bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "17:43"
|
||||
float(17.730%d)
|
||||
int(1218197630)
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
|
||||
--unset var--
|
||||
string(5) "17:43"
|
||||
float(17.730%d)
|
||||
int(1218197630)
|
||||
float(17.731%d)
|
||||
int(1218197632)
|
||||
===DONE===
|
||||
|
@ -104,13 +104,13 @@ foreach($inputs as $key =>$value) {
|
||||
|
||||
--int 0--
|
||||
string(5) "00:03"
|
||||
float(0.059%d)
|
||||
int(1218220414)
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--int 1--
|
||||
string(5) "23:59"
|
||||
float(23.992%d)
|
||||
int(1218220174)
|
||||
float(23.995%d)
|
||||
int(1218220185)
|
||||
|
||||
--int 12345--
|
||||
string(5) "17:15"
|
||||
@ -118,9 +118,9 @@ float(17.259%d)
|
||||
int(1218195932)
|
||||
|
||||
--int -12345--
|
||||
string(5) "12:18"
|
||||
float(12.316%d)
|
||||
int(1218178138)
|
||||
string(5) "12:19"
|
||||
float(12.319%d)
|
||||
int(1218178151)
|
||||
|
||||
--empty array--
|
||||
|
||||
@ -168,33 +168,33 @@ bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "00:03"
|
||||
float(0.059%d)
|
||||
int(1218220414)
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "00:03"
|
||||
float(0.059%d)
|
||||
int(1218220414)
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "23:59"
|
||||
float(23.992%d)
|
||||
int(1218220174)
|
||||
float(23.995%d)
|
||||
int(1218220185)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "00:03"
|
||||
float(0.059%d)
|
||||
int(1218220414)
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "23:59"
|
||||
float(23.992%d)
|
||||
int(1218220174)
|
||||
float(23.995%d)
|
||||
int(1218220185)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "00:03"
|
||||
float(0.059%d)
|
||||
int(1218220414)
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
@ -286,11 +286,11 @@ bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "00:03"
|
||||
float(0.059%d)
|
||||
int(1218220414)
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
|
||||
--unset var--
|
||||
string(5) "00:03"
|
||||
float(0.059%d)
|
||||
int(1218220414)
|
||||
float(0.062%d)
|
||||
int(1218220425)
|
||||
===DONE===
|
||||
|
@ -114,8 +114,8 @@ bool(false)
|
||||
|
||||
--int 12345--
|
||||
string(5) "19:20"
|
||||
float(19.340%d)
|
||||
int(1218203424)
|
||||
float(19.343%d)
|
||||
int(1218203437)
|
||||
|
||||
--int -12345--
|
||||
bool(false)
|
||||
|
@ -103,24 +103,24 @@ foreach($inputs as $key =>$value) {
|
||||
*** Testing date_sunset() : usage variation ***
|
||||
|
||||
--int 0--
|
||||
string(5) "12:40"
|
||||
float(12.681%d)
|
||||
int(1218199253)
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--int 1--
|
||||
string(5) "13:40"
|
||||
float(13.681%d)
|
||||
int(1218199253)
|
||||
string(5) "13:41"
|
||||
float(13.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--int 12345--
|
||||
string(5) "21:40"
|
||||
float(21.681%d)
|
||||
int(1218199253)
|
||||
string(5) "21:41"
|
||||
float(21.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--int -12345--
|
||||
string(5) "19:40"
|
||||
float(19.681%d)
|
||||
int(1218199253)
|
||||
string(5) "19:41"
|
||||
float(19.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--empty array--
|
||||
|
||||
@ -167,34 +167,34 @@ Warning: date_sunset() expects parameter 6 to be float, array given in %s on lin
|
||||
bool(false)
|
||||
|
||||
--uppercase NULL--
|
||||
string(5) "12:40"
|
||||
float(12.681%d)
|
||||
int(1218199253)
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--lowercase null--
|
||||
string(5) "12:40"
|
||||
float(12.681%d)
|
||||
int(1218199253)
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--lowercase true--
|
||||
string(5) "13:40"
|
||||
float(13.681%d)
|
||||
int(1218199253)
|
||||
string(5) "13:41"
|
||||
float(13.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--lowercase false--
|
||||
string(5) "12:40"
|
||||
float(12.681%d)
|
||||
int(1218199253)
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--uppercase TRUE--
|
||||
string(5) "13:40"
|
||||
float(13.681%d)
|
||||
int(1218199253)
|
||||
string(5) "13:41"
|
||||
float(13.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--uppercase FALSE--
|
||||
string(5) "12:40"
|
||||
float(12.681%d)
|
||||
int(1218199253)
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--empty string DQ--
|
||||
|
||||
@ -285,12 +285,12 @@ Warning: date_sunset() expects parameter 6 to be float, object given in %s on li
|
||||
bool(false)
|
||||
|
||||
--undefined var--
|
||||
string(5) "12:40"
|
||||
float(12.681%d)
|
||||
int(1218199253)
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
|
||||
--unset var--
|
||||
string(5) "12:40"
|
||||
float(12.681%d)
|
||||
int(1218199253)
|
||||
string(5) "12:41"
|
||||
float(12.684%d)
|
||||
int(1218199264)
|
||||
===DONE===
|
||||
|
@ -42,24 +42,24 @@ string(5) "18:13"
|
||||
string(5) "18:13"
|
||||
|
||||
--US/Alaska--
|
||||
string(5) "21:00"
|
||||
string(5) "20:57"
|
||||
string(5) "21:02"
|
||||
string(5) "20:59"
|
||||
|
||||
--America/Chicago--
|
||||
string(5) "19:52"
|
||||
string(5) "19:51"
|
||||
string(5) "19:50"
|
||||
|
||||
--America/Montevideo--
|
||||
string(5) "18:08"
|
||||
string(5) "18:09"
|
||||
string(5) "18:08"
|
||||
|
||||
--Africa/Casablanca--
|
||||
string(5) "19:18"
|
||||
string(5) "19:17"
|
||||
string(5) "19:16"
|
||||
|
||||
--Europe/Moscow--
|
||||
string(5) "21:09"
|
||||
string(5) "21:07"
|
||||
string(5) "21:10"
|
||||
string(5) "21:08"
|
||||
|
||||
--Asia/Hong_Kong--
|
||||
string(5) "18:55"
|
||||
|
@ -16,27 +16,27 @@ for($a=1;$a<=12;$a++){
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
1041395864 06:37 6.6290131458%d
|
||||
1041432452 16:47 16.792451114%d
|
||||
1044073855 06:30 6.5154089279%d
|
||||
1044112463 17:14 17.239870289%d
|
||||
1046491495 06:04 6.0822145033%d
|
||||
1046533075 17:37 17.632011035%d
|
||||
1049167581 05:26 5.4394438111%d
|
||||
1049212774 17:59 17.993035729%d
|
||||
1051757532 04:52 4.8701934126%d
|
||||
1051806007 18:20 18.335390508%d
|
||||
1054434776 04:32 4.5489827182%d
|
||||
1054485647 18:40 18.679812949%d
|
||||
1057026949 04:35 4.5971956372%d
|
||||
1057078197 18:49 18.832563396%d
|
||||
1059706409 04:53 4.8916575089%d
|
||||
1059755837 18:37 18.621440704%d
|
||||
1062385999 05:13 5.2220951121%d
|
||||
1062432291 18:04 18.080957168%d
|
||||
1064979098 05:31 5.5273199215%d
|
||||
1065021952 17:25 17.431339135%d
|
||||
1067658845 05:54 5.9016292870%d
|
||||
1067698274 16:51 16.853902453%d
|
||||
1070252387 06:19 6.3299242689%d
|
||||
1070289382 16:36 16.606312600%d
|
||||
1041395858 06:37 6.6274307083%d
|
||||
1041432434 16:47 16.787476435%d
|
||||
1044073871 06:31 6.5198435465%d
|
||||
1044112440 17:14 17.233560530%d
|
||||
1046491524 06:05 6.0901858662%d
|
||||
1046533056 17:37 17.626724279%d
|
||||
1049167610 05:26 5.4473483216%d
|
||||
1049212759 17:59 17.988854003%d
|
||||
1051757554 04:52 4.8761196793%d
|
||||
1051805991 18:19 18.330987470%d
|
||||
1054434782 04:33 4.5506171719%d
|
||||
1054485634 18:40 18.676282498%d
|
||||
1057026940 04:35 4.5946862151%d
|
||||
1057078197 18:49 18.832651294%d
|
||||
1059706395 04:53 4.8875657219%d
|
||||
1059755854 18:37 18.626282855%d
|
||||
1062385985 05:13 5.2182752537%d
|
||||
1062432319 18:05 18.088728929%d
|
||||
1064979083 05:31 5.5233314120%d
|
||||
1065021981 17:26 17.439368589%d
|
||||
1067658825 05:53 5.8959513887%d
|
||||
1067698295 16:51 16.859972460%d
|
||||
1070252367 06:19 6.3241991396%d
|
||||
1070289384 16:36 16.606870705%d
|
||||
|
@ -26,18 +26,18 @@ var_dump( $abbr["acst"] );
|
||||
--EXPECTF--
|
||||
*** Testing timezone_abbreviations_list() : basic functionality ***
|
||||
string(5) "array"
|
||||
int(%d)
|
||||
int(142)
|
||||
|
||||
-- Format a sample entry --
|
||||
array(11) {
|
||||
array(12) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(true)
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(-14400)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(18) "America/Porto_Acre"
|
||||
string(18) "Australia/Adelaide"
|
||||
}
|
||||
[1]=>
|
||||
array(3) {
|
||||
@ -51,47 +51,47 @@ array(11) {
|
||||
[2]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(true)
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(-14400)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(16) "America/Eirunepe"
|
||||
string(21) "Australia/Broken_Hill"
|
||||
}
|
||||
[3]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(true)
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(-14400)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(18) "America/Rio_Branco"
|
||||
string(16) "Australia/Darwin"
|
||||
}
|
||||
[4]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(true)
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(-14400)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(11) "Brazil/Acre"
|
||||
string(15) "Australia/North"
|
||||
}
|
||||
[5]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(13) "Asia/Jayapura"
|
||||
string(15) "Australia/South"
|
||||
}
|
||||
[6]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
int(32400)
|
||||
["timezone_id"]=>
|
||||
string(21) "Australia/Broken_Hill"
|
||||
string(20) "Australia/Yancowinna"
|
||||
}
|
||||
[7]=>
|
||||
array(3) {
|
||||
@ -100,7 +100,7 @@ array(11) {
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
["timezone_id"]=>
|
||||
string(16) "Australia/Darwin"
|
||||
string(21) "Australia/Broken_Hill"
|
||||
}
|
||||
[8]=>
|
||||
array(3) {
|
||||
@ -109,7 +109,7 @@ array(11) {
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
["timezone_id"]=>
|
||||
string(15) "Australia/North"
|
||||
string(16) "Australia/Darwin"
|
||||
}
|
||||
[9]=>
|
||||
array(3) {
|
||||
@ -118,9 +118,18 @@ array(11) {
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
["timezone_id"]=>
|
||||
string(15) "Australia/South"
|
||||
string(15) "Australia/North"
|
||||
}
|
||||
[10]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
["offset"]=>
|
||||
int(34200)
|
||||
["timezone_id"]=>
|
||||
string(15) "Australia/South"
|
||||
}
|
||||
[11]=>
|
||||
array(3) {
|
||||
["dst"]=>
|
||||
bool(false)
|
||||
|
@ -24,11 +24,6 @@ var_dump( timezone_name_from_abbr("EDT") );
|
||||
echo "-- Lookup with name and offset--\n";
|
||||
var_dump( timezone_name_from_abbr("ADT", -10800) );
|
||||
var_dump( timezone_name_from_abbr("ADT", 14400) );
|
||||
var_dump( timezone_name_from_abbr("AKTT", 14400) );
|
||||
var_dump( timezone_name_from_abbr("aktt", 18000) );
|
||||
var_dump( timezone_name_from_abbr("Aktt", 21600) );
|
||||
var_dump( timezone_name_from_abbr("AMST", -10800) );
|
||||
var_dump( timezone_name_from_abbr("amst", 180000) );
|
||||
|
||||
echo "-- Tests without valid name - uses gmtOffset and isdst to find match --\n";
|
||||
var_dump( timezone_name_from_abbr("", 3600, 1) );
|
||||
@ -51,12 +46,7 @@ string(13) "Europe/Berlin"
|
||||
string(16) "America/New_York"
|
||||
-- Lookup with name and offset--
|
||||
string(15) "America/Halifax"
|
||||
string(12) "Asia/Baghdad"
|
||||
string(11) "Asia/Aqtobe"
|
||||
string(11) "Asia/Aqtobe"
|
||||
string(11) "Asia/Aqtobe"
|
||||
string(17) "America/Boa_Vista"
|
||||
string(12) "Asia/Yerevan"
|
||||
string(15) "America/Halifax"
|
||||
-- Tests without valid name - uses gmtOffset and isdst to find match --
|
||||
string(13) "Europe/London"
|
||||
string(17) "America/Sao_Paulo"
|
||||
@ -65,4 +55,4 @@ string(15) "America/Halifax"
|
||||
-- Tests with invalid offsets --
|
||||
bool(false)
|
||||
bool(false)
|
||||
===DONE===
|
||||
===DONE===
|
||||
|
@ -56,8 +56,8 @@ U_CFUNC TimeZone *timezone_convert_datetimezone(int type,
|
||||
break;
|
||||
case TIMELIB_ZONETYPE_OFFSET: {
|
||||
int offset_mins = is_datetime
|
||||
? -((php_date_obj*)object)->time->z
|
||||
: -(int)((php_timezone_obj*)object)->tzi.utc_offset,
|
||||
? ((php_date_obj*)object)->time->z / 60
|
||||
: (int)((php_timezone_obj*)object)->tzi.utc_offset / 60,
|
||||
hours = offset_mins / 60,
|
||||
minutes = offset_mins - hours * 60;
|
||||
minutes *= minutes > 0 ? 1 : -1;
|
||||
|
@ -83,8 +83,8 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone,
|
||||
* so we must mess with DateTimeZone structure ourselves */
|
||||
tzobj->initialized = 1;
|
||||
tzobj->type = TIMELIB_ZONETYPE_OFFSET;
|
||||
//convert offset from milliseconds to minutes
|
||||
tzobj->tzi.utc_offset = -1 * timeZone->getRawOffset() / (60 * 1000);
|
||||
//convert offset from milliseconds to seconds
|
||||
tzobj->tzi.utc_offset = timeZone->getRawOffset() / 1000;
|
||||
} else {
|
||||
zend_string *u8str;
|
||||
/* Call the constructor! */
|
||||
|
Loading…
Reference in New Issue
Block a user