diff options
author | Derick Rethans <derick@php.net> | 2008-04-25 12:35:58 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2008-04-25 12:35:58 +0000 |
commit | 2047fa858c1775742b84501701845b86f8a2a47f (patch) | |
tree | 776ce164736845353be8b0a6c1993f4ccceec7ea /ext/date/lib/timelib.c | |
parent | c173b0454c2aaaed04138c4f28fe3cf6deeb945a (diff) | |
download | php-git-2047fa858c1775742b84501701845b86f8a2a47f.tar.gz |
- Added new date/time functionality:
. support for diffing date/times through date_diff() / DateTime::diff().
. added DateInterval class to represent the difference between two date/times.
. support for parsing ISO intervals for use with DateInterval.
. date_add() / DateTime::add(), date_sub() / DateTime::sub() for applying an
interval to an existing date/time.
- MFH: Fixed bug #44742 (timezone_offset_get() causes segmentation faults).
Diffstat (limited to 'ext/date/lib/timelib.c')
-rw-r--r-- | ext/date/lib/timelib.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c index c6e019abac..064237ffb3 100644 --- a/ext/date/lib/timelib.c +++ b/ext/date/lib/timelib.c @@ -38,6 +38,14 @@ timelib_time* timelib_time_ctor(void) return t; } +timelib_rel_time* timelib_rel_time_ctor(void) +{ + timelib_rel_time *t; + t = calloc(1, sizeof(timelib_rel_time)); + + return t; +} + void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr) { unsigned int i; @@ -55,6 +63,11 @@ void timelib_time_dtor(timelib_time* t) 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; @@ -114,6 +127,7 @@ void timelib_tzinfo_dtor(timelib_tzinfo *tz) TIMELIB_TIME_FREE(tz->timezone_abbr); TIMELIB_TIME_FREE(tz->leap_times); TIMELIB_TIME_FREE(tz); + tz = NULL; } char *timelib_get_tz_abbr_ptr(timelib_time *t) @@ -228,3 +242,20 @@ void timelib_dump_date(timelib_time *d, int options) printf("\n"); } +void timelib_dump_rel_time(timelib_rel_time *d) +{ + printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS (days: %lld)%s", + d->y, d->m, d->d, d->h, d->i, d->s, d->days, d->invert ? " inverted" : ""); + if (d->first_last_day_of != 0) { + switch (d->first_last_day_of) { + case 1: + printf(" / first day of"); + break; + case 2: + printf(" / last day of"); + break; + } + } + printf("\n"); +} + |