30FILE_RCSID(
"@(#)$File: cdf_time.c,v 1.24 2023/07/17 15:54:44 christos Exp $")
41#define isleap(y) ((((y) % 4) == 0) && \
42 ((((y) % 100) != 0) || (((y) % 400) == 0)))
44static const int mdays[] = {
45 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
67cdf_getday(
int year,
int days)
72 int sub = mdays[m] + (m == 1 &&
isleap(year));
84cdf_getmonth(
int year,
int days)
90 if (m == 1 &&
isleap(year))
102#ifdef HAVE_STRUCT_TM_TM_ZONE
103 static char UTC[] =
"UTC";
111 tm.tm_sec =
CAST(
int, t % 60);
114 tm.tm_min =
CAST(
int, t % 60);
117 tm.tm_hour =
CAST(
int, t % 24);
123 rdays = cdf_getdays(tm.tm_year);
125 tm.tm_mday = cdf_getday(tm.tm_year,
CAST(
int, t));
126 tm.tm_mon = cdf_getmonth(tm.tm_year,
CAST(
int, t));
130#ifdef HAVE_STRUCT_TM_TM_GMTOFF
133#ifdef HAVE_STRUCT_TM_TM_ZONE
155 if (gmtime_r(&ts->ts_sec, &tm) ==
NULL) {
161 *t += tm.tm_min * 60;
162 *t += tm.tm_hour * 60 * 60;
163 *t += tm.tm_mday * 60 * 60 * 24;
176 CAST(
long long, *sec));
179 CAST(
long long, *sec));
187main(
int argc,
char *argv[])
192 static const char *ref =
"Sat Apr 23 01:30:00 1977";
200 errx(1,
"Error date %s != %s\n", ref,
p);
strchr(string $haystack, string $needle, bool $before_needle=false)
char * cdf_ctime(const time_t *sec, char *buf)
int cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t)
int cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
zend_ffi_ctype_name_buf buf
char * ctime_r(const time_t *, char *)
mktime(int $hour, ?int $minute=null, ?int $second=null, ?int $month=null, ?int $day=null, ?int $year=null)
strcmp(string $string1, string $string2)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)