7 #define TIME_HFS_SINCE_1970 2082844800u
8 #define TIME_W32_SINCE_1970 0x2b6109100ull
12 #elif __APPLE__ && !defined(MAC_OS_X_VERSION_10_12)
13 #include <mach/mach_time.h>
32 static int tzflag = 0;
37 GetSystemTimeAsFileTime(&ft);
41 ul |= ft.dwHighDateTime;
43 ul |= ft.dwLowDateTime;
49 ul -= 11644473600000000ULL;
54 p->tv_sec = (
long)(ul / 1000000LL);
55 p->tv_usec = (
long)(ul % 1000000LL);
62 tz->tz_minuteswest = _timezone / 60;
63 tz->tz_dsttime = _daylight;
105 if (!QueryPerformanceFrequency(&
f)) {
109 if (!QueryPerformanceCounter(&
v)) {
112 v.QuadPart *= 1000000;
113 v.QuadPart /=
f.QuadPart;
115 #elif __APPLE__ && !defined(MAC_OS_X_VERSION_10_12)
116 ut64 ticks = mach_absolute_time();
117 mach_timebase_info_data_t tb;
118 mach_timebase_info(&tb);
122 clock_gettime(CLOCK_MONOTONIC, &now);
129 if (
time->tm_mday == 31 &&
time->tm_mon == 11 &&
time->tm_year == 69) {
130 return time->tm_hour * 3600 +
time->tm_min * 60 +
time->tm_sec;
131 }
else if (
time->tm_mon == 0 &&
time->tm_year == 70) {
132 return 86400 + (
time->tm_mday - 1) * 86400 +
time->tm_hour * 3600 +
time->tm_min * 60 +
time->tm_sec;
153 if (gmt_tm.tm_mday == 1 && gmt_tm.tm_mon == 0 && gmt_tm.tm_year == 70) {
156 diff = local_time - gmt_time;
158 gmt_time = mktime(&gmt_tm);
159 local_time = mktime(&local_tm);
160 diff = (
long)difftime(local_time, gmt_time);
162 bool err = gmt_time == -1 || local_time == -1;
166 long hours = diff / 3600;
167 long minutes = labs(diff % 3600 / 60);
168 long seconds = labs(diff % 3600 % 60);
171 }
else if (seconds) {
172 timestr =
rz_str_newf(
"%s UTC%+ld:%ld:%ld", timestr, hours, minutes, seconds);
173 }
else if (minutes) {
174 timestr =
rz_str_newf(
"%s UTC%+ld:%ld", timestr, hours, minutes);
176 timestr =
rz_str_newf(
"%s UTC%+ld", timestr, hours);
191 ut16 date = timestamp >> 16;
195 ut32 year = ((date & 0xfe00) >> 9) + 1980;
196 ut32 month = (date & 0x01e0) >> 5;
197 ut32 day = date & 0x001f;
201 ut32 minutes = (
time & 0x07e0) >> 5;
202 ut32 seconds = (
time & 0x001f) << 1;
206 t.tm_year = year - 1900;
207 t.tm_mon = month > 0 ? month - 1 : month;
208 t.tm_mday = day > 0 ? day : 1;
213 time_t epochTime = mktime(&t);
215 return (
ut32)epochTime;
227 if ((certainPosixTimeStamp >> 16) == (possiblePosixOrDosTimeStamp >> 16)) {
262 timestamp /= 10000000ll;
287 errno_t
err = localtime_s(res,
time);
290 return localtime_r(
time, res);
297 errno_t
err = gmtime_s(res,
time);
300 return gmtime_r(
time, res);
310 return asctime_r(tm,
buf);
320 return ctime_r(timer,
buf);
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog gettimeofday
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags long
static static fork const void static count static fd const char const char static newpath char char char static envp time
#define rz_return_val_if_fail(expr, val)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API void rz_str_trim(RZ_NONNULL RZ_INOUT char *str)
Removes whitespace characters (space, tab, newline etc.) from the beginning and end of a string.
#define ASCTIME_BUF_MINLEN
RZ_API RZ_OWN char * rz_time_date_dos_to_string(ut32 timestamp)
Converts a dos date (ut32) and returns the timestamp in string format.
#define TIME_W32_SINCE_1970
RZ_API RZ_OWN char * rz_time_date_now_to_string(void)
Returns the timestamp in string format of the current time (now)
RZ_API struct tm * rz_localtime_r(RZ_NONNULL const time_t *time, RZ_NONNULL struct tm *res)
RZ_API struct tm * rz_gmtime_r(RZ_NONNULL const time_t *time, RZ_NONNULL struct tm *res)
RZ_API bool rz_time_stamp_is_dos_format(const ut32 certainPosixTimeStamp, const ut32 possiblePosixOrDosTimeStamp)
Verifies that the timestamp is in dos format.
RZ_API char * rz_asctime_r(RZ_NONNULL const struct tm *tm, RZ_NONNULL char *buf)
RZ_API RZ_OWN char * rz_time_date_w32_to_string(ut64 timestamp)
Converts a Win32 date (ut64) and returns the timestamp in string format.
RZ_API ut64 rz_time_now(void)
Returns the current time in microseconds.
RZ_API int rz_time_gettimeofday(struct timeval *p, struct timezone *tz)
Get the system current time and the current time zone.
#define TIME_HFS_SINCE_1970
RZ_API RZ_OWN char * rz_time_date_hfs_to_string(ut32 timestamp)
Converts a Mac HFS+ date (ut32) and returns the timestamp in string format.
RZ_API RZ_OWN char * rz_time_stamp_to_str(ut32 timestamp)
Converts an unix epoch timestamp to string.
static long get_seconds_since_12am31Dec1969(struct tm *time)
RZ_API char * rz_ctime_r(RZ_NONNULL const time_t *timer, RZ_NONNULL char *buf)
RZ_API ut64 rz_time_now_mono(void)
Returns the current time in microseconds, using the monotonic clock.
RZ_API ut32 rz_time_dos_time_stamp_to_posix(ut32 timestamp)
Converts dos timestamp to posix timestamp.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()