cases.
void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr)
{
- int i;
+ unsigned int i;
TIMELIB_TIME_FREE(tm->tz_abbr);
tm->tz_abbr = strdup(tz_abbr);
if (error) {
*error = 0;
}
- return d->sse;
+ return (signed long) d->sse;
}
void timelib_dump_date(timelib_time *d, int options)
/* From dow.c */
-int timelib_day_of_week(int y, int m, int d);
-int timelib_daynr_from_weeknr(int y, int w, int d);
+timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
+timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d);
/* From parse_date.re */
timelib_time *timelib_strtotime(char *s);
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 */
-static int century_value(int j)
+static timelib_sll century_value(timelib_sll j)
{
- int i = j - 17;
- int c = (4 - i * 2 + (i + 1) / 4) % 7;
+ timelib_sll i = j - 17;
+ timelib_sll c = (4 - i * 2 + (i + 1) / 4) % 7;
return c < 0 ? c + 7 : c;
}
-int timelib_day_of_week(int y, int m, int d)
+timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d)
{
- int c1, y1, m1;
+ timelib_sll c1, y1, m1;
/* Only valid for Gregorian calendar */
if (y < 1753) {
return (c1 + y1 + m1 + (y1 / 4) + d) % 7;
}
-int timelib_daynr_from_weeknr(int y, int w, int d)
+timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d)
{
- int dow, day;
+ timelib_sll dow, day;
/* Figure out the dayofweek for y-1-1 */
dow = timelib_day_of_week(y, 1, 1);
-/* Generated by re2c 0.9.8.dev on Wed Jun 15 11:08:32 2005 */
+/* Generated by re2c 0.9.8.dev on Wed Jun 15 12:56:03 2005 */
#line 1 "parse_date.re"
/*
+----------------------------------------------------------------------+
#define TIMELIB_RELATIVE 310
-#define ERROR 999
+#define TIMELIB_ERROR 999
typedef unsigned char uchar;
#define timelib_string_free free
-#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return 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_HAVE_TIME() { if (s->time->have_time) { 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) { return ERROR; } else { s->time->have_date = 1; } }
+#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { 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_weekday_relative = 1; }
-#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return ERROR; } else { s->time.have_zone = 1; } }
+#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } }
#define TIMELIB_INIT s->cur = cursor; str = timelib_string(s); ptr = str
#define TIMELIB_DEINIT timelib_string_free(str)
int multiplier;
} timelib_relunit;
-#define HOUR(a) (a * 60)
+#define HOUR(a) (int)(a * 60)
/* The timezone table. */
static timelib_tz_lookup_table const timelib_timezone_lookup[] = {
}
#endif
-static int timelib_meridian(char **ptr, int h)
+static timelib_sll timelib_meridian(char **ptr, timelib_sll h)
{
- int retval = 0;
+ timelib_sll retval = 0;
while (!strchr("AaPp", **ptr)) {
++*ptr;
return tmp_nr;
}
-static float timelib_get_frac_nr(char **ptr, int max_length)
+static double timelib_get_frac_nr(char **ptr, int max_length)
{
char *begin, *end, *str;
- float tmp_nr = -1;
+ double tmp_nr = -1;
int len = 0;
while ((**ptr != '.') && ((**ptr < '0') || (**ptr > '9'))) {
return value;
}
-static void timelib_set_relative(char **ptr, long amount, Scanner *s)
+static void timelib_set_relative(char **ptr, timelib_ull amount, Scanner *s)
{
const timelib_relunit* relunit;
yy3:
YYDEBUG(3, *YYCURSOR);
-#line 1262 "parse_date.re"
+#line 1263 "parse_date.re"
{
TIMELIB_INIT;
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time);
yy7:
YYDEBUG(7, *YYCURSOR);
-#line 1322 "parse_date.re"
+#line 1323 "parse_date.re"
{
/* printf("unexpected character: #%d, %c\n", *s->tok, *s->tok); */
goto std;
yy44:
YYDEBUG(44, *YYCURSOR);
-#line 1311 "parse_date.re"
+#line 1312 "parse_date.re"
{
goto std;
}
yy46:
YYDEBUG(46, *YYCURSOR);
-#line 1316 "parse_date.re"
+#line 1317 "parse_date.re"
{
s->pos = cursor; s->line++;
goto std;
yy81:
YYDEBUG(81, *YYCURSOR);
-#line 1295 "parse_date.re"
+#line 1296 "parse_date.re"
{
timelib_ull i;
yy148:
YYDEBUG(148, *YYCURSOR);
-#line 1257 "parse_date.re"
+#line 1258 "parse_date.re"
{
goto std;
}
yy155:
YYDEBUG(155, *YYCURSOR);
-#line 1241 "parse_date.re"
+#line 1242 "parse_date.re"
{
const timelib_relunit* relunit;
yy188:
YYDEBUG(188, *YYCURSOR);
-#line 1225 "parse_date.re"
+#line 1226 "parse_date.re"
{
long i;
yy386:
YYDEBUG(386, *YYCURSOR);
-#line 1098 "parse_date.re"
+#line 1099 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy397:
YYDEBUG(397, *YYCURSOR);
-#line 1074 "parse_date.re"
+#line 1075 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy404:
YYDEBUG(404, *YYCURSOR);
-#line 1171 "parse_date.re"
+#line 1172 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy423:
YYDEBUG(423, *YYCURSOR);
-#line 1270 "parse_date.re"
+#line 1271 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy559:
YYDEBUG(559, *YYCURSOR);
-#line 1211 "parse_date.re"
+#line 1212 "parse_date.re"
{
TIMELIB_INIT;
s->time->relative.y = 0 - s->time->relative.y;
yy669:
YYDEBUG(669, *YYCURSOR);
-#line 930 "parse_date.re"
+#line 931 "parse_date.re"
{
DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long");
TIMELIB_INIT;
yy684:
YYDEBUG(684, *YYCURSOR);
-#line 915 "parse_date.re"
+#line 916 "parse_date.re"
{
DEBUG_OUTPUT("timeshort12 | timelong12");
TIMELIB_INIT;
yy697:
YYDEBUG(697, *YYCURSOR);
-#line 1050 "parse_date.re"
+#line 1051 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy756:
YYDEBUG(756, *YYCURSOR);
-#line 1062 "parse_date.re"
+#line 1063 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy801:
YYDEBUG(801, *YYCURSOR);
-#line 1038 "parse_date.re"
+#line 1039 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy805:
YYDEBUG(805, *YYCURSOR);
-#line 1013 "parse_date.re"
+#line 1014 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy838:
YYDEBUG(838, *YYCURSOR);
-#line 1195 "parse_date.re"
+#line 1196 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_TIME();
yy878:
YYDEBUG(878, *YYCURSOR);
-#line 1183 "parse_date.re"
+#line 1184 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy898:
YYDEBUG(898, *YYCURSOR);
-#line 1086 "parse_date.re"
+#line 1087 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy919:
YYDEBUG(919, *YYCURSOR);
-#line 1152 "parse_date.re"
+#line 1153 "parse_date.re"
{
- int w, d;
+ timelib_sll w, d;
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy923:
YYDEBUG(923, *YYCURSOR);
-#line 1140 "parse_date.re"
+#line 1141 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy930:
YYDEBUG(930, *YYCURSOR);
-#line 1110 "parse_date.re"
+#line 1111 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy941:
YYDEBUG(941, *YYCURSOR);
-#line 1121 "parse_date.re"
+#line 1122 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_TIME();
yy1035:
YYDEBUG(1035, *YYCURSOR);
-#line 1027 "parse_date.re"
+#line 1028 "parse_date.re"
{
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
yy1116:
YYDEBUG(1116, *YYCURSOR);
-#line 952 "parse_date.re"
+#line 953 "parse_date.re"
{
DEBUG_OUTPUT("gnunocolon");
TIMELIB_INIT;
break;
default:
TIMELIB_DEINIT;
- return ERROR;
+ return TIMELIB_ERROR;
}
s->time->have_time++;
TIMELIB_DEINIT;
yy1124:
YYDEBUG(1124, *YYCURSOR);
-#line 997 "parse_date.re"
+#line 998 "parse_date.re"
{
DEBUG_OUTPUT("iso8601nocolon");
TIMELIB_INIT;
s->time->y = 1970;
s->time->m = 1;
s->time->d = 1;
- s->time->h = s->time->i = s->time->s = s->time->f = 0;
+ s->time->h = s->time->i = s->time->s = 0;
+ s->time->f = 0.0;
s->time->relative.s += i;
s->time->is_localtime = 1;
s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 10670 "<stdout>"
+#line 10671 "<stdout>"
yy1141:
YYDEBUG(1141, *YYCURSOR);
yych = *++YYCURSOR;
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 10711 "<stdout>"
+#line 10712 "<stdout>"
yy1150:
YYDEBUG(1150, *YYCURSOR);
yych = *++YYCURSOR;
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 10731 "<stdout>"
+#line 10732 "<stdout>"
yy1153:
YYDEBUG(1153, *YYCURSOR);
yych = *++YYCURSOR;
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 10756 "<stdout>"
+#line 10757 "<stdout>"
yy1156:
YYDEBUG(1156, *YYCURSOR);
yych = *++YYCURSOR;
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 10796 "<stdout>"
+#line 10797 "<stdout>"
}
}
-#line 1326 "parse_date.re"
+#line 1327 "parse_date.re"
}
#define TIMELIB_RELATIVE 310
-#define ERROR 999
+#define TIMELIB_ERROR 999
typedef unsigned char uchar;
#define timelib_string_free free
-#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return 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_HAVE_TIME() { if (s->time->have_time) { 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) { return ERROR; } else { s->time->have_date = 1; } }
+#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { 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_weekday_relative = 1; }
-#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return ERROR; } else { s->time.have_zone = 1; } }
+#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } }
#define TIMELIB_INIT s->cur = cursor; str = timelib_string(s); ptr = str
#define TIMELIB_DEINIT timelib_string_free(str)
int multiplier;
} timelib_relunit;
-#define HOUR(a) (a * 60)
+#define HOUR(a) (int)(a * 60)
/* The timezone table. */
static timelib_tz_lookup_table const timelib_timezone_lookup[] = {
}
#endif
-static int timelib_meridian(char **ptr, int h)
+static timelib_sll timelib_meridian(char **ptr, timelib_sll h)
{
- int retval = 0;
+ timelib_sll retval = 0;
while (!strchr("AaPp", **ptr)) {
++*ptr;
return tmp_nr;
}
-static float timelib_get_frac_nr(char **ptr, int max_length)
+static double timelib_get_frac_nr(char **ptr, int max_length)
{
char *begin, *end, *str;
- float tmp_nr = -1;
+ double tmp_nr = -1;
int len = 0;
while ((**ptr != '.') && ((**ptr < '0') || (**ptr > '9'))) {
return value;
}
-static void timelib_set_relative(char **ptr, long amount, Scanner *s)
+static void timelib_set_relative(char **ptr, timelib_ull amount, Scanner *s)
{
const timelib_relunit* relunit;
s->time->y = 1970;
s->time->m = 1;
s->time->d = 1;
- s->time->h = s->time->i = s->time->s = s->time->f = 0;
+ s->time->h = s->time->i = s->time->s = 0;
+ s->time->f = 0.0;
s->time->relative.s += i;
s->time->is_localtime = 1;
s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
break;
default:
TIMELIB_DEINIT;
- return ERROR;
+ return TIMELIB_ERROR;
}
s->time->have_time++;
TIMELIB_DEINIT;
break;
default:
TIMELIB_DEINIT;
- return ERROR;
+ return TIMELIB_ERROR;
}
s->time->have_time++;
TIMELIB_DEINIT;
isoweekday
{
- int w, d;
+ timelib_sll w, d;
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
static void read_transistions(char **tzf, timelib_tzinfo *tz)
{
- int32_t *buffer = NULL, i;
+ int32_t *buffer = NULL;
+ uint32_t i;
unsigned char *cbuffer = NULL;
if (tz->timecnt) {
static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts)
{
- int i;
+ uint32_t i;
if (!tz->timecnt || !tz->trans) {
return NULL;
#define TIMELIB_RELATIVE 310
-#define ERROR 999
+#define TIMELIB_ERROR 999
typedef unsigned char uchar;
#define timelib_string_free free
-#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return 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_HAVE_TIME() { if (s->time->have_time) { 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) { return ERROR; } else { s->time->have_date = 1; } }
+#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { 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_weekday_relative = 1; }
-#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return ERROR; } else { s->time.have_zone = 1; } }
+#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } }
#define TIMELIB_INIT s->cur = cursor; str = timelib_string(s); ptr = str
#define TIMELIB_DEINIT timelib_string_free(str)
int multiplier;
} timelib_relunit;
-#define HOUR(a) (a * 60)
+#define HOUR(a) (int)(a * 60)
/* The timezone table. */
static timelib_tz_lookup_table const timelib_timezone_lookup[] = {
}
#endif
-static int timelib_meridian(char **ptr, int h)
+static timelib_sll timelib_meridian(char **ptr, timelib_sll h)
{
- int retval = 0;
+ timelib_sll retval = 0;
while (!strchr("AaPp", **ptr)) {
++*ptr;
return tmp_nr;
}
-static float timelib_get_frac_nr(char **ptr, int max_length)
+static double timelib_get_frac_nr(char **ptr, int max_length)
{
char *begin, *end, *str;
- float tmp_nr = -1;
+ double tmp_nr = -1;
int len = 0;
while ((**ptr != '.') && ((**ptr < '0') || (**ptr > '9'))) {
return value;
}
-static void timelib_set_relative(char **ptr, long amount, Scanner *s)
+static void timelib_set_relative(char **ptr, timelib_ull amount, Scanner *s)
{
const timelib_relunit* relunit;
s->time->y = 1970;
s->time->m = 1;
s->time->d = 1;
- s->time->h = s->time->i = s->time->s = s->time->f = 0;
+ s->time->h = s->time->i = s->time->s = 0;
+ s->time->f = 0.0;
s->time->relative.s += i;
s->time->is_localtime = 1;
s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
break;
default:
TIMELIB_DEINIT;
- return ERROR;
+ return TIMELIB_ERROR;
}
s->time->have_time++;
TIMELIB_DEINIT;
break;
default:
TIMELIB_DEINIT;
- return ERROR;
+ return TIMELIB_ERROR;
}
s->time->have_time++;
TIMELIB_DEINIT;
isoweekday
{
- int w, d;
+ timelib_sll w, d;
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
typedef struct timelib_time {
timelib_sll y, m, d; /* Year, Month, Day */
timelib_sll h, i, s; /* Hour, mInute, Second */
- float f; /* Fraction */
+ double f; /* Fraction */
int z; /* GMT offset in minutes */
char *tz_abbr; /* Timezone abbreviation (display only) */
timelib_tzinfo *tz_info; /* Timezone structure */
static int do_range_limit_days(timelib_sll *y, timelib_sll *m, timelib_sll *d)
{
- int leapyear;
- int days_this_month;
- int last_month, last_year;
- int days_last_month;
+ timelib_sll leapyear;
+ timelib_sll days_this_month;
+ timelib_sll last_month, last_year;
+ timelib_sll days_last_month;
do_range_limit(1, 13, 12, m, y);
static void do_adjust_for_weekday(timelib_time* time)
{
- int current_dow, difference;
+ timelib_sll current_dow, difference;
current_dow = timelib_day_of_week(time->y, time->m, time->d);
difference = time->relative.weekday - current_dow;
memset(&(time->relative), 0, sizeof(time->relative));
}
-static timelib_sll do_years(int year)
+static timelib_sll do_years(timelib_sll year)
{
- unsigned int i;
+ timelib_sll i;
timelib_sll res = 0;
if (year >= 1970) {
return res;
}
-static timelib_sll do_months(unsigned int month, unsigned int year)
+static timelib_sll do_months(timelib_ull month, timelib_ull year)
{
if (is_leap(year)) {
return ((month_tab_leap[month - 1] + 1) * SECS_PER_DAY);
}
}
-static timelib_sll do_days(unsigned int day)
+static timelib_sll do_days(timelib_ull day)
{
return ((day - 1) * SECS_PER_DAY);
}
-static timelib_sll do_time(unsigned int hour, unsigned int minute, unsigned int second)
+static timelib_sll do_time(timelib_ull hour, timelib_ull minute, timelib_ull second)
{
timelib_sll res = 0;