2005-06-14 21:32:29 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| PHP Version 5 |
|
|
|
|
+----------------------------------------------------------------------+
|
2007-12-31 07:12:20 +00:00
|
|
|
| Copyright (c) 1997-2008 The PHP Group |
|
2005-06-14 21:32:29 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 13:10:10 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2005-06-14 21:32:29 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 13:10:10 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2005-06-14 21:32:29 +00:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2005-06-17 14:54:00 +00:00
|
|
|
| Authors: Derick Rethans <derick@derickrethans.nl> |
|
2005-06-14 21:32:29 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2005-06-16 17:12:41 +00:00
|
|
|
#include "timelib.h"
|
2005-06-14 21:32:29 +00:00
|
|
|
|
|
|
|
/* 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 };
|
|
|
|
static int month_tab[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
|
|
|
|
|
|
|
|
/* dec jan feb mrt apr may jun jul aug sep oct nov dec */
|
|
|
|
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 int do_range_limit(timelib_sll start, timelib_sll end, timelib_sll adj, timelib_sll *a, timelib_sll *b)
|
|
|
|
{
|
|
|
|
if (*a < start) {
|
|
|
|
*a += adj;
|
|
|
|
(*b)--;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (*a >= end) {
|
|
|
|
if (start == 0) {
|
|
|
|
(*b) += (*a / end);
|
|
|
|
(*a) -= (end * (*a / end));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*a -= adj;
|
|
|
|
(*b)++;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-25 12:55:16 +00:00
|
|
|
static int do_range_limit_days_relative(timelib_sll *base_y, timelib_sll *base_m, timelib_sll *y, timelib_sll *m, timelib_sll *d)
|
|
|
|
{
|
|
|
|
timelib_sll leapyear;
|
|
|
|
timelib_sll days_this_month;
|
|
|
|
timelib_sll next_month, next_year;
|
|
|
|
timelib_sll days_next_month;
|
|
|
|
|
|
|
|
do_range_limit(1, 13, 12, base_m, base_y);
|
|
|
|
|
|
|
|
leapyear = timelib_is_leap(*base_y);
|
|
|
|
days_this_month = leapyear ? days_in_month_leap[*base_m] : days_in_month[*base_m];
|
|
|
|
next_month = (*base_m) + 1;
|
|
|
|
|
|
|
|
if (next_month > 12) {
|
|
|
|
next_month -= 12;
|
|
|
|
next_year = (*base_y) + 1;
|
|
|
|
} else {
|
|
|
|
next_year = (*base_y);
|
|
|
|
}
|
|
|
|
leapyear = timelib_is_leap(next_year);
|
|
|
|
days_next_month = leapyear ? days_in_month_leap[next_month] : days_in_month[next_month];
|
|
|
|
|
|
|
|
if (*d < 0) {
|
|
|
|
*d += days_this_month;
|
|
|
|
(*m)--;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (*d > days_next_month) {
|
|
|
|
*d -= days_next_month;
|
|
|
|
(*m)++;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-14 21:32:29 +00:00
|
|
|
static int do_range_limit_days(timelib_sll *y, timelib_sll *m, timelib_sll *d)
|
|
|
|
{
|
2005-06-15 11:01:07 +00:00
|
|
|
timelib_sll leapyear;
|
|
|
|
timelib_sll days_this_month;
|
|
|
|
timelib_sll last_month, last_year;
|
|
|
|
timelib_sll days_last_month;
|
2005-06-14 21:32:29 +00:00
|
|
|
|
|
|
|
do_range_limit(1, 13, 12, m, y);
|
|
|
|
|
2005-06-30 21:38:06 +00:00
|
|
|
leapyear = timelib_is_leap(*y);
|
2005-06-14 21:32:29 +00:00
|
|
|
days_this_month = leapyear ? days_in_month_leap[*m] : days_in_month[*m];
|
|
|
|
last_month = (*m) - 1;
|
|
|
|
|
|
|
|
if (last_month < 1) {
|
|
|
|
last_month += 12;
|
|
|
|
last_year = (*y) - 1;
|
|
|
|
} else {
|
|
|
|
last_year = (*y);
|
|
|
|
}
|
2005-06-30 21:38:06 +00:00
|
|
|
leapyear = timelib_is_leap(last_year);
|
2005-06-14 21:32:29 +00:00
|
|
|
days_last_month = leapyear ? days_in_month_leap[last_month] : days_in_month[last_month];
|
|
|
|
|
|
|
|
if (*d <= 0) {
|
|
|
|
*d += days_last_month;
|
|
|
|
(*m)--;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (*d > days_this_month) {
|
|
|
|
*d -= days_this_month;
|
|
|
|
(*m)++;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_adjust_for_weekday(timelib_time* time)
|
|
|
|
{
|
2005-06-15 11:01:07 +00:00
|
|
|
timelib_sll current_dow, difference;
|
2005-06-14 21:32:29 +00:00
|
|
|
|
|
|
|
current_dow = timelib_day_of_week(time->y, time->m, time->d);
|
2008-04-27 19:12:10 +00:00
|
|
|
if (time->relative.weekday_behavior == 2)
|
|
|
|
{
|
|
|
|
if (time->relative.weekday == 0) {
|
|
|
|
time->relative.weekday = 7;
|
|
|
|
}
|
|
|
|
time->d -= current_dow;
|
|
|
|
time->d += time->relative.weekday;
|
|
|
|
return;
|
|
|
|
}
|
2005-06-14 21:32:29 +00:00
|
|
|
difference = time->relative.weekday - current_dow;
|
2005-10-19 21:11:15 +00:00
|
|
|
if ((time->relative.d < 0 && difference < 0) || (time->relative.d >= 0 && difference <= -time->relative.weekday_behavior)) {
|
2005-06-14 21:32:29 +00:00
|
|
|
difference += 7;
|
|
|
|
}
|
|
|
|
if (time->relative.weekday >= 0) {
|
|
|
|
time->d += difference;
|
|
|
|
} else {
|
|
|
|
time->d -= (7 - (abs(time->relative.weekday) - current_dow));
|
|
|
|
}
|
2008-05-01 16:14:29 +00:00
|
|
|
time->relative.have_weekday_relative = 0;
|
2005-06-14 21:32:29 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 12:55:16 +00:00
|
|
|
void timelib_do_rel_normalize(timelib_time *base, timelib_rel_time *rt)
|
|
|
|
{
|
|
|
|
do {} while (do_range_limit(0, 60, 60, &rt->s, &rt->i));
|
|
|
|
do {} while (do_range_limit(0, 60, 60, &rt->i, &rt->h));
|
|
|
|
do {} while (do_range_limit(0, 24, 24, &rt->h, &rt->d));
|
|
|
|
do {} while (do_range_limit(0, 12, 12, &rt->m, &rt->y));
|
|
|
|
|
|
|
|
do {} while (do_range_limit_days_relative(&base->y, &base->m, &rt->y, &rt->m, &rt->d));
|
|
|
|
do {} while (do_range_limit(0, 12, 12, &rt->m, &rt->y));
|
|
|
|
}
|
|
|
|
|
2005-06-14 21:32:29 +00:00
|
|
|
static void do_normalize(timelib_time* time)
|
|
|
|
{
|
|
|
|
do {} while (do_range_limit(0, 60, 60, &time->s, &time->i));
|
|
|
|
do {} while (do_range_limit(0, 60, 60, &time->i, &time->h));
|
|
|
|
do {} while (do_range_limit(0, 24, 24, &time->h, &time->d));
|
|
|
|
do {} while (do_range_limit(1, 13, 12, &time->m, &time->y));
|
|
|
|
|
|
|
|
do {} while (do_range_limit_days(&time->y, &time->m, &time->d));
|
|
|
|
do {} while (do_range_limit(1, 13, 12, &time->m, &time->y));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_adjust_relative(timelib_time* time)
|
|
|
|
{
|
2008-05-01 16:14:29 +00:00
|
|
|
if (time->relative.have_weekday_relative) {
|
2006-05-14 17:30:26 +00:00
|
|
|
do_adjust_for_weekday(time);
|
|
|
|
}
|
|
|
|
do_normalize(time);
|
|
|
|
|
2005-06-14 21:32:29 +00:00
|
|
|
if (time->have_relative) {
|
|
|
|
time->s += time->relative.s;
|
|
|
|
time->i += time->relative.i;
|
|
|
|
time->h += time->relative.h;
|
|
|
|
|
|
|
|
time->d += time->relative.d;
|
|
|
|
time->m += time->relative.m;
|
|
|
|
time->y += time->relative.y;
|
|
|
|
}
|
2008-02-03 14:10:48 +00:00
|
|
|
switch (time->relative.first_last_day_of) {
|
|
|
|
case 1: // first
|
|
|
|
time->d = 1;
|
|
|
|
break;
|
|
|
|
case 2: // last
|
|
|
|
time->d = 0;
|
|
|
|
time->m++;
|
|
|
|
break;
|
|
|
|
}
|
2005-06-14 21:32:29 +00:00
|
|
|
do_normalize(time);
|
2006-05-14 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_adjust_special_weekday(timelib_time* time)
|
|
|
|
{
|
2008-05-03 10:03:21 +00:00
|
|
|
timelib_sll current_dow, count;
|
2006-05-14 17:30:26 +00:00
|
|
|
|
2008-05-01 16:14:29 +00:00
|
|
|
count = time->relative.special.amount;
|
2008-05-03 10:03:21 +00:00
|
|
|
|
|
|
|
current_dow = timelib_day_of_week(time->y, time->m, time->d);
|
2006-05-14 17:30:26 +00:00
|
|
|
if (count == 0) {
|
2008-05-03 10:03:21 +00:00
|
|
|
// skip over saturday and sunday
|
2006-05-14 17:30:26 +00:00
|
|
|
if (current_dow == 6) {
|
2008-05-03 10:03:21 +00:00
|
|
|
time->d += 2;
|
2006-05-14 17:30:26 +00:00
|
|
|
}
|
2008-05-03 10:03:21 +00:00
|
|
|
// skip over sunday
|
2006-05-14 17:30:26 +00:00
|
|
|
if (current_dow == 0) {
|
2008-05-03 10:03:21 +00:00
|
|
|
time->d += 1;
|
2006-05-14 17:30:26 +00:00
|
|
|
}
|
|
|
|
} else if (count > 0) {
|
2008-05-03 10:03:21 +00:00
|
|
|
// skip over saturday and sunday
|
2006-05-14 17:30:26 +00:00
|
|
|
if (current_dow == 5) {
|
2008-05-03 10:03:21 +00:00
|
|
|
time->d += 2;
|
2006-05-14 17:30:26 +00:00
|
|
|
}
|
2008-05-03 10:03:21 +00:00
|
|
|
// skip over sunday
|
2006-05-14 17:30:26 +00:00
|
|
|
if (current_dow == 6) {
|
2008-05-03 10:03:21 +00:00
|
|
|
time->d += 1;
|
2006-05-14 17:30:26 +00:00
|
|
|
}
|
2008-05-03 10:03:21 +00:00
|
|
|
// add increments of 5 weekdays as a week
|
|
|
|
time->d += (count / 5) * 7;
|
|
|
|
// if current DOW plus the remainder > 5, add two days
|
|
|
|
current_dow = timelib_day_of_week(time->y, time->m, time->d);
|
|
|
|
time->d += (count % 5);
|
|
|
|
if ((count % 5) + current_dow > 5) {
|
|
|
|
time->d += 2;
|
2006-05-14 17:30:26 +00:00
|
|
|
}
|
2008-05-03 10:03:21 +00:00
|
|
|
} else if (count < 0) {
|
|
|
|
// skip over sunday and saturday
|
2006-05-14 17:30:26 +00:00
|
|
|
if (current_dow == 1) {
|
2008-05-03 10:03:21 +00:00
|
|
|
time->d -= 2;
|
|
|
|
}
|
|
|
|
// skip over satruday
|
|
|
|
if (current_dow == 0 ) {
|
|
|
|
time->d -= 1;
|
|
|
|
}
|
|
|
|
// subtract increments of 5 weekdays as a week
|
|
|
|
time->d += (count / 5) * 7;
|
|
|
|
// if current DOW minus the remainder < 0, subtract two days
|
|
|
|
current_dow = timelib_day_of_week(time->y, time->m, time->d);
|
|
|
|
time->d += (count % 5);
|
|
|
|
if ((count % 5) + current_dow < 1) {
|
|
|
|
time->d -= 2;
|
2006-05-14 17:30:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_adjust_special(timelib_time* time)
|
|
|
|
{
|
2008-05-01 16:14:29 +00:00
|
|
|
if (time->relative.have_special_relative) {
|
|
|
|
switch (time->relative.special.type) {
|
2006-05-14 17:30:26 +00:00
|
|
|
case TIMELIB_SPECIAL_WEEKDAY:
|
|
|
|
do_adjust_special_weekday(time);
|
|
|
|
break;
|
|
|
|
}
|
2005-06-14 21:32:29 +00:00
|
|
|
}
|
|
|
|
do_normalize(time);
|
2008-05-01 16:14:29 +00:00
|
|
|
memset(&(time->relative.special), 0, sizeof(time->relative.special));
|
2005-06-14 21:32:29 +00:00
|
|
|
}
|
|
|
|
|
2008-05-04 20:50:46 +00:00
|
|
|
static void do_adjust_special_early(timelib_time* time)
|
|
|
|
{
|
|
|
|
if (time->relative.have_special_relative) {
|
|
|
|
switch (time->relative.special.type) {
|
|
|
|
case TIMELIB_SPECIAL_DAY_OF_WEEK_IN_MONTH:
|
|
|
|
time->d = 1;
|
|
|
|
time->m += time->relative.m;
|
|
|
|
time->relative.m = 0;
|
|
|
|
break;
|
|
|
|
case TIMELIB_SPECIAL_LAST_DAY_OF_WEEK_IN_MONTH:
|
|
|
|
time->d = 1;
|
|
|
|
time->m += time->relative.m + 1;
|
|
|
|
time->relative.m = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-15 11:01:07 +00:00
|
|
|
static timelib_sll do_years(timelib_sll year)
|
2005-06-14 21:32:29 +00:00
|
|
|
{
|
2005-06-15 11:01:07 +00:00
|
|
|
timelib_sll i;
|
2005-06-14 21:32:29 +00:00
|
|
|
timelib_sll res = 0;
|
2006-04-11 17:56:49 +00:00
|
|
|
timelib_sll eras;
|
|
|
|
|
|
|
|
eras = (year - 1970) / 400;
|
|
|
|
if (eras != 0) {
|
|
|
|
year = year - (eras * 400);
|
|
|
|
res += (SECS_PER_ERA * eras);
|
|
|
|
}
|
2005-06-14 21:32:29 +00:00
|
|
|
|
|
|
|
if (year >= 1970) {
|
|
|
|
for (i = year - 1; i >= 1970; i--) {
|
2005-06-30 21:38:06 +00:00
|
|
|
if (timelib_is_leap(i)) {
|
2005-06-14 21:32:29 +00:00
|
|
|
res += (DAYS_PER_LYEAR * SECS_PER_DAY);
|
|
|
|
} else {
|
|
|
|
res += (DAYS_PER_YEAR * SECS_PER_DAY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 1969; i >= year; i--) {
|
2005-06-30 21:38:06 +00:00
|
|
|
if (timelib_is_leap(i)) {
|
2005-06-14 21:32:29 +00:00
|
|
|
res -= (DAYS_PER_LYEAR * SECS_PER_DAY);
|
|
|
|
} else {
|
|
|
|
res -= (DAYS_PER_YEAR * SECS_PER_DAY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2005-06-15 11:01:07 +00:00
|
|
|
static timelib_sll do_months(timelib_ull month, timelib_ull year)
|
2005-06-14 21:32:29 +00:00
|
|
|
{
|
2005-06-30 21:38:06 +00:00
|
|
|
if (timelib_is_leap(year)) {
|
2005-06-14 21:32:29 +00:00
|
|
|
return ((month_tab_leap[month - 1] + 1) * SECS_PER_DAY);
|
|
|
|
} else {
|
|
|
|
return ((month_tab[month - 1]) * SECS_PER_DAY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-15 11:01:07 +00:00
|
|
|
static timelib_sll do_days(timelib_ull day)
|
2005-06-14 21:32:29 +00:00
|
|
|
{
|
|
|
|
return ((day - 1) * SECS_PER_DAY);
|
|
|
|
}
|
|
|
|
|
2005-06-15 11:01:07 +00:00
|
|
|
static timelib_sll do_time(timelib_ull hour, timelib_ull minute, timelib_ull second)
|
2005-06-14 21:32:29 +00:00
|
|
|
{
|
|
|
|
timelib_sll res = 0;
|
|
|
|
|
|
|
|
res += hour * 3600;
|
|
|
|
res += minute * 60;
|
|
|
|
res += second;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static timelib_sll do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
|
|
|
|
{
|
|
|
|
switch (tz->zone_type) {
|
|
|
|
case TIMELIB_ZONETYPE_OFFSET:
|
|
|
|
|
|
|
|
tz->is_localtime = 1;
|
|
|
|
return tz->z * 60;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIMELIB_ZONETYPE_ABBR: {
|
|
|
|
timelib_sll tmp;
|
|
|
|
|
|
|
|
tz->is_localtime = 1;
|
|
|
|
tmp = tz->z;
|
|
|
|
tmp -= tz->dst * 60;
|
|
|
|
tmp *= 60;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIMELIB_ZONETYPE_ID:
|
2005-06-17 14:11:12 +00:00
|
|
|
tzi = tz->tz_info;
|
|
|
|
/* Break intentionally missing */
|
2005-06-14 21:32:29 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
/* No timezone in struct, fallback to reference if possible */
|
|
|
|
if (tzi) {
|
|
|
|
timelib_time_offset *before, *after;
|
2005-06-18 19:23:58 +00:00
|
|
|
timelib_sll tmp;
|
|
|
|
int in_transistion;
|
2005-06-14 21:32:29 +00:00
|
|
|
|
|
|
|
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);
|
2005-06-18 19:23:58 +00:00
|
|
|
|
|
|
|
in_transistion = (
|
|
|
|
((tz->sse - after->offset) >= (after->transistion_time + (before->offset - after->offset))) &&
|
|
|
|
((tz->sse - after->offset) < after->transistion_time)
|
|
|
|
);
|
|
|
|
|
|
|
|
if ((before->offset != after->offset) && !in_transistion) {
|
|
|
|
tmp = -after->offset;
|
2005-06-14 21:32:29 +00:00
|
|
|
} else {
|
2005-06-15 23:42:55 +00:00
|
|
|
tmp = -tz->z;
|
2005-06-14 21:32:29 +00:00
|
|
|
}
|
2005-06-15 23:42:55 +00:00
|
|
|
timelib_time_offset_dtor(before);
|
|
|
|
timelib_time_offset_dtor(after);
|
2008-04-25 12:55:16 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
timelib_time_offset *gmt_offset;
|
|
|
|
|
|
|
|
gmt_offset = timelib_get_time_zone_info(tz->sse + tmp, tzi);
|
|
|
|
tz->z = gmt_offset->offset;
|
|
|
|
|
|
|
|
tz->dst = gmt_offset->is_dst;
|
|
|
|
if (tz->tz_abbr) {
|
|
|
|
free(tz->tz_abbr);
|
|
|
|
}
|
|
|
|
tz->tz_abbr = strdup(gmt_offset->abbr);
|
|
|
|
timelib_time_offset_dtor(gmt_offset);
|
|
|
|
}
|
2005-06-15 23:42:55 +00:00
|
|
|
return tmp;
|
2005-06-14 21:32:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi)
|
|
|
|
{
|
|
|
|
timelib_sll res = 0;
|
|
|
|
|
2008-05-04 20:50:46 +00:00
|
|
|
do_adjust_special_early(time);
|
2005-06-14 21:32:29 +00:00
|
|
|
do_adjust_relative(time);
|
2006-05-14 17:30:26 +00:00
|
|
|
do_adjust_special(time);
|
2005-06-14 21:32:29 +00:00
|
|
|
res += do_years(time->y);
|
|
|
|
res += do_months(time->m, time->y);
|
|
|
|
res += do_days(time->d);
|
|
|
|
res += do_time(time->h, time->i, time->s);
|
|
|
|
time->sse = res;
|
|
|
|
|
|
|
|
res += do_adjust_timezone(time, tzi);
|
|
|
|
time->sse = res;
|
|
|
|
|
|
|
|
time->sse_uptodate = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
timelib_sll res;
|
|
|
|
timelib_time time;
|
|
|
|
|
|
|
|
time = timelib_strtotime("10 Feb 2005 06:07:03 PM CET"); /* 1108055223 */
|
|
|
|
printf ("%04d-%02d-%02d %02d:%02d:%02d.%-5d %+04d %1d",
|
|
|
|
time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
|
|
|
|
if (time.have_relative) {
|
|
|
|
printf ("%3dY %3dM %3dD / %3dH %3dM %3dS",
|
|
|
|
time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative.s);
|
|
|
|
}
|
|
|
|
if (time.have_weekday_relative) {
|
|
|
|
printf (" / %d", time.relative.weekday);
|
|
|
|
}
|
|
|
|
res = time2unixtime(&time);
|
|
|
|
printf("%Ld\n", res);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|