20#if !defined WIN32_LEAN_AND_MEAN
21#define WIN32_LEAN_AND_MEAN
30#include <mach/clock.h>
32#include <mach/mach_time.h>
35#include <osl/diagnose.h>
40constexpr sal_Int32 ConvertYMDToInt(sal_Int32 nYear, sal_Int32 nMonth, sal_Int32 nDay)
42 return (nYear * 10000) + (nMonth * 100) + nDay;
45constexpr sal_Int64 ConvertHMSnToInt(sal_Int64 nHour, sal_Int64 nMin, sal_Int64 nSec,
56 GetLocalTime(&aDateTime);
59 *pDate = ConvertYMDToInt(
static_cast<sal_Int32
>(aDateTime.wYear),
60 static_cast<sal_Int32
>(aDateTime.wMonth),
61 static_cast<sal_Int32
>(aDateTime.wDay));
63 *pTime = ConvertHMSnToInt(aDateTime.wHour, aDateTime.wMinute, aDateTime.wSecond,
64 aDateTime.wMilliseconds * 1000000);
68 struct timespec tsTime;
73 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
74 clock_get_time(cclock, &mts);
75 mach_port_deallocate(mach_task_self(), cclock);
76 tsTime.tv_sec = mts.tv_sec;
77 tsTime.tv_nsec = mts.tv_nsec;
81 if (clock_gettime(CLOCK_REALTIME, &tsTime) != 0)
83 struct timeval tvTime;
84 OSL_VERIFY(gettimeofday(&tvTime,
nullptr) != 0);
85 tsTime.tv_sec = tvTime.tv_sec;
86 tsTime.tv_nsec = tvTime.tv_usec * 1000;
91 time_t nTmpTime = tsTime.tv_sec;
92 if (localtime_r(&nTmpTime, &aTime))
95 *pDate = ConvertYMDToInt(
static_cast<sal_Int32
>(aTime.tm_year + 1900),
96 static_cast<sal_Int32
>(aTime.tm_mon + 1),
97 static_cast<sal_Int32
>(aTime.tm_mday));
99 *pTime = ConvertHMSnToInt(aTime.tm_hour, aTime.tm_min, aTime.tm_sec, tsTime.tv_nsec);
bool GetSystemDateTime(sal_Int32 *pDate, sal_Int64 *pTime)
Get current local timestamp.
constexpr sal_Int64 SEC_MASK
constexpr sal_Int64 HOUR_MASK
constexpr sal_Int64 MIN_MASK
TransliterationModules tm