The “C” programming language is one of the most popular computer languages in the history of computing. The Y2038 issue originated in “C”, while it was being developed along with UNIX. The ‘heart’ of the Y2038 issue is the representation of time in seconds as a 32-bit integer (usually via a variable of type time_t). “time_t” is usually a 32-bit signed integer on 32-bit systems, and 64-bit signed integer on 64-bit systems. The epoch is usually midnight on Jan 1, 1970. The maximum number of seconds that can be represented in a 32-bit quantity will be exceeded after Jan 19, 2038 at 3:14:07 GMT.
One very appealing aspect of “C” is that it gives programmers absolute power and flexibility, but of course this also means that even small programming errors or bad assumptions can cause unintended consequences. As one example, any variable in “C” can be cast to another type, either implicitly or explicitly. If a cast is implicit (and there is a loss of precision), the compiler will at least print a warning. If a cast is explicit, the compiler may not even print a warning. As a case in point, if a programmer writing code on a 64-bit platform explicitly casts a variable of type time_t to another variable which happens to be a 32-bit signed integer, nothing bad may happen until the Y2038 rollover. After that time, what happens will depend on the program, but generally it won’t be good!
When faced with the task of finding and addressing Y2038 in “C” code, one approach is to search for all time-related functions. However, the usage of time in “C” is a fairly complex subject. There are numerous API functions, data structures, data types, and environment variables related to time. Even though “C” is standardized, significant differences do exist between implementations on different platforms. Each platform’s implementation can also evolve over time.
The table below is an attempt to list all API functions, data structures, data types, and environment variables having to do with time for some of the most popular platforms, including Linux, Microsoft Windows, Apple OSX, and VxWorks. Columns are also included for ISO and POSIX standards. As there are multiple versions of ISO and POSIX standards, the columns provided generally reflect the most recent versions. (This table is an ongoing work in progress. Over time, we plan to include additional platforms and additional links to external references (e.g. MSDN pages, etc.). Many such links are already included. Please let us know if you find errors or omissions, or have other suggestions.
On 32-bit platforms, any and all use of time in any way could be the source of Y2038 issues. On 64-bit systems, the platform usually provides a 64-bit time, which makes it possible to be Y2038 compliant. However, it is possible that variables with values of time in seconds get cast into 32-bit integers, perhaps when printing or conversion of some sort, or other processing. We therefore strongly advise that *ALL* usage of time be checked for Y2038 issues, even on 64-bit systems.
Please note that Y2038 issues are possible in “C” code outside of all standard uses. This is because times can come from external sources, such as embedded binary fields within network protocols and databases. Therefore, the approach of finding and fixing all of the functions listed below will not necessarily correct all Y2038 issues.
Category | Name | Header | C11 (ISO) | POSIX | Linux | Windows | Mac OSX | VxWorks | Description |
---|---|---|---|---|---|---|---|---|---|
Constant/Definition | _USE_32BIT_TIME_T | n/a | No | No | No | Yes | No | No | On 64-bit Windows, forces time_t to 32-bits |
Constant/Definition | __DARWIN_CLK_TCK | i386/_limits.h | No | No | No | No | Yes (100) | No | CLOCKS_PER_SECOND when __DARWIN_UNIX03 not defined |
Constant/Definition | _POSIX_TZNAME_MAX | limits.h | No | Yes | No | No | Yes | Yes | Max length of the tzname variable |
Constant/Definition | _SC_CLK_TCK | unistd.h | No | Yes | Yes | No | Yes | No | The system clock rate in ticks per sec |
Constant/Definition | _XTIME_NSECS_PER_TICK | thr/xtimec.h | No | No | No | Yes | No | No | # nsecs per tick (as related to xtime), defined as 100 |
Constant/Definition | _XTIME_TICKS_PER_TIME_T | thr/xtimec.h | No | No | No | 10M | No | No | # ticks per sec (as related to xtime), defined as 10M (__LONGLONG) |
Constant/Definition | CLK_TCK | Varies | No | No* | Yes* | Yes | Yes | No | The system clock rate in ticks per sec (* = marked as obsolete) |
Constant/Definition | CLOCKS_PER_SEC | time.h | Yes | 1M | 1M | 1000 | 1M or 100 | sysClockRateGet | The system clock rate in ticks per sec |
Constant/Definition | TZNAME_MAX | limits.h | No | Yes | Yes | Yes | No | No | Max length of the tzname variable |
CPU Usage | clock | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Gets the CPU time used, returned in a clock_t |
CPU Usage | getrusage | sys/resource.h | No | Yes | Yes | No | Yes | No | Gets info about resource utilization, returned in rusage structure |
Current Time | _ftime | sys/timeb.h | No | No | No | Yes | No | No | Gets current time in secs by calling _ftime32 or _ftime64 |
Current Time | _ftime_s | sys/timeb.h | No | No | No | Yes | No | No | Gets current time in secs by calling _ftime32_s or ftime64_s |
Current Time | _ftime32 | sys/timeb.h | No | No | No | Yes | No | No | Gets current time in secs from Jan 1, 1970, limited to Jan 19, 2038 |
Current Time | _ftime32_s | sys/timeb.h | No | No | No | Yes | No | No | Gets current time in secs from Jan 1, 1970, limited to Jan 19, 2038 |
Current Time | _ftime64 | sys/timeb.h | No | No | No | Yes | No | No | Gets current time in secs from Jan 1, 1970, limited to Dec 31, 3000 |
Current Time | _ftime64_s | sys/timeb.h | No | No | No | Yes | No | No | Gets current time in secs from Jan 1, 1970, limited to Dec 31, 3001 |
Current Time | _time32 | time.h | No | No | No | Yes | No | No | Windows function for getting time in 32-bit time_t |
Current Time | _time64 | time.h | No | No | No | Yes | No | No | Windows function for getting time in 64-bit time_t |
Current Time | ftime | sys/timeb.h | No | No* | Yes | Yes | Yes | No | Gets current time in secs and msecs since epoch of Jan 1, 1970 as timeb |
Current Time | GetDynamicTimeZoneInformation | Windows.h | No | No | No | Yes | No | No | Returns the current timezone and dynamic DST settings |
Current Time | GetFileAttributesEx | Windows.h | No | No | No | Yes | No | No | Returns various data including FILETIMEs for create, write, and access |
Current Time | GetFileTime | Windows.h | No | No | No | Yes | No | No | Returns the (creation, last access, and last write) times for a file or folder |
Current Time | GetLocalTime | Windows.h | No | No | No | Yes | No | No | Gets the current system time (local time format), in a SYSTEMTIME struct |
Current Time | GetSystemTime | Windows.h | No | No | No | Yes | No | No | Gets the current system time (UTC format), in SYSTEMTIME struct |
Current Time | GetSystemTimeAdjustment | Windows.h | No | No | No | Yes | No | No | Gets system clock adjustments, 100 nsec units in DWORD |
Current Time | GetSystemTimeAsFileTime | Windows.h | No | No | No | Yes | No | No | Gets accurate system time in UTC format as a FILETIME |
Current Time | GetSystemTimePreciseAsFileTime | Windows.h | No | No | No | Yes | No | No | Gets accurate system time in UTC format as a FILETIME |
Current Time | GetSystemTimes | Windows.h | No | No | No | Yes | No | No | Gets idle, kernel, and user times in FILETIME structs |
Current Time | GetTickCount | Windows.h | No | No | No | Yes | No | No | Gets # of msecs since system start, rolls over after 49.7 days |
Current Time | GetTickCount64 | Windows.h | No | No | No | Yes | No | No | Gets # of msecs since system start, with resolution of 10-16 msecs |
Current Time | gettimeofday | sys/time.h | No | Yes* | Yes | No | Yes | No | Gets current date/time as a timeval struct |
Current Time | SetDynamicTimeZoneInformation | Windows.h | No | No | No | Yes | No | No | Sets the current timezone and dynamic DST settings |
Current Time | SetFileTime | Windows.h | No | No | No | Yes | No | No | Sets the (creation, last access, and last write) times for a file or folder |
Current Time | SetLocalTime | Windows.h | No | No | No | Yes | No | No | Sets the current local date and time |
Current Time | SetSystemTime | Windows.h | No | No | No | Yes | No | No | Sets the current system time using SYSTEMTIME struct with UTC |
Current Time | SetSystemTimeAdjustment | Windows.h | No | No | No | Yes | No | No | Controls periodic adjustments to system clock, 100 nsec units in DWORD |
Current Time | settimeofday | sys/time.h | No | No | Yes | No | Yes | No | Sets current system time based on value in timeval struct |
Current Time | stime | time.h | No | No | Yes | No | No | No | Sets current system time based on value in time_t |
Current Time | time | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Gets time since epoch in a time_t |
Env Variable | _daylight | n/a | No | No | No | Yes | No | No | Nonzero if DST is specified in TZ or determined from the OS, otherwise 0 |
Env Variable | _dstbias | n/a | No | No | No | Yes | No | No | Difference between standard and DST in seconds |
Env Variable | _timezone | n/a | No | No | No | Yes | No | No | Difference between UTC and local time in seconds |
Env Variable | _tzname[0] | n/a | No | No | No | Yes | No | No | Non-DST zone name derived from TZ, e.g. "PST" |
Env Variable | _tzname[1] | n/a | No | No | No | Yes | No | No | DST zone name derived from TZ, e.g. "PDT" |
Env Variable | DATE | n/a | No | No | No | Yes | No | No | Holds the current date, e.g. "Fri 12/25/2015" |
Env Variable | DATEMSK | n/a | No | Yes | Yes | No | Yes | No | Indicates the pathname of the template file used by getdate() |
Env Variable | HZ | n/a | No | No | Yes | No | No | No | Tells # of timer interrupts per second, infrequently used |
Env Variable | TIME | n/a | No | No | No | Yes | No | No | Holds the current time, e.g. "23:42:49.56" |
Env Variable | TIMEZONE | n/a | No | No | No | No | No | Yes | Represents timezone information |
Env Variable | TZ | n/a | No | Yes | Yes | Yes | Yes | No | Represents timezone information |
Env Variable | TZDIR | n/a | No | No | Yes | No | No | No | Used by glibc to specify an alternate timezone information file |
File System | _fstat | sys/stat.h | No | No | No | Yes | Yes | No | Gets info about open file, using _stat struct |
File System | _fstat32 | sys/stat.h | No | No | No | Yes | No | No | Gets info about open file, using _stat32 struct |
File System | _fstat32i64 | sys/stat.h | No | No | No | Yes | No | No | Gets info about open file, using _stat32i64 struct |
File System | _fstat64 | sys/stat.h | No | No | No | Yes | No | No | Gets info about open file, using __stat64 struct |
File System | _fstat64i32 | sys/stat.h | No | No | No | Yes | No | No | Gets info about open file, using _stat64i32 struct |
File System | _fstati64 | sys/stat.h | No | No | No | Yes | No | No | Gets info about open file, using _stati64 struct |
File System | _futime | sys/utime.h | No | No | No | Yes | No | No | Sets mod time on open file, using _utimbuf struct |
File System | _futime32 | sys/utime.h | No | No | No | Yes | No | No | Sets mod time on open file, using _utimbuf32 struct |
File System | _futime64 | sys/utime.h | No | No | No | Yes | No | No | Sets mod time on open file, using _utimbuf64 struct |
File System | _stat | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stat struct |
File System | _stat32 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stat32 struct |
File System | _stat32i64 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stat32i64 struct |
File System | _stat64 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as __stat64 struct |
File System | _stat64i32 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stat64i32 struct |
File System | _stati64 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stati64 struct |
File System | _utime | sys/utime.h | No | No | No | Yes | No | No | Sets mod time on file, using _utimbuf struct |
File System | _utime32 | sys/utime.h | No | No | No | Yes | No | No | Sets mod time on file, using _utimbuf32 struct |
File System | _utime64 | sys/utime.h | No | No | No | Yes | No | No | Sets mod time on file, using _utimbuf64 struct |
File System | _wstat | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stat struct |
File System | _wstat32 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stat32 struct |
File System | _wstat32i64 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stat32i64 struct |
File System | _wstat64 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as __stat64 struct |
File System | _wstat64i32 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stat64i32 struct |
File System | _wstati64 | sys/stat.h | No | No | No | Yes | No | No | Gets info about a file, returned as _stati64 struct |
File System | _wutime | sys/utime.h | No | No | No | Yes | No | No | Sets mod time on file, using _utimbuf struct |
File System | _wutime32 | sys/utime.h | No | No | No | Yes | No | No | Sets mod time on file, using _utimbuf32 struct |
File System | _wutime64 | sys/utime.h | No | No | No | Yes | No | No | Sets mod time on file, using _utimbuf64 struct |
File System | fstat | sys/stat.h | No | Yes | Yes | Yes | Yes | Yes | Gets info about open file, returned in stat struct |
File System | fstat64 | sys/stat.h | No | No | No | No | Yes | No | Gets info about open file, returned in stat64 struct |
File System | fstatat | sys/stat.h | No | Yes | Yes | Yes | Yes | No | Get info about an open file relative to given path, returned in stat struct |
File System | fstatat64 | sys/stat.h | No | No | No | No | Yes | No | Get info about an open file relative to given path, returned in stat64 struct |
File System | GetFileTime | Windows.h | No | No | No | Yes | No | No | Gets create, last write, and last access times for file opened with CreateFile |
File System | lstat | sys/stat.h | No | Yes | Yes | No | Yes | No | Gets info about a symbolic link, returned in stat struct |
File System | lstat64 | sys/stat.h | No | No | Yes | No | Yes | No | Gets info about a symbolic link, returned in stat64 struct |
File System | stat | sys/stat.h | No | Yes | Yes | Yes | Yes | Yes | Gets info about a file, returned in stat struct |
File System | stat64 | sys/stat.h | No | No | No | No | Yes | No | Gets info about a file, returned in stat64 struct |
File System | utime | utime.h | No | Yes | Yes | Yes | Yes | Yes | Set file access and mod times, using utimbuf struct |
Format Conv | _ctime32 | time.h | No | No | No | Yes | No | No | Convert a time32_t to a date/time string |
Format Conversion | _ctime32_s | time.h | No | No | No | Yes | No | No | Convert a time32_t to a date/time string |
Format Conversion | _ctime64 | time.h | No | No | No | Yes | No | No | Convert a time64_t to a date/time string |
Format Conversion | _ctime64_s | time.h | No | No | No | Yes | No | No | Convert a time64_t to a date/time string |
Format Conversion | _gmtime32 | time.h | No | No | No | Yes | No | No | Convert a time32_t to a tm struct |
Format Conversion | _gmtime32_s | time.h | No | No | No | Yes | No | No | Convert a time32_t to a tm struct |
Format Conversion | _gmtime64 | time.h | No | No | No | Yes | No | No | Convert a time64_t to a tm struct |
Format Conversion | _gmtime64_s | time.h | No | No | No | Yes | No | No | Convert a time64_t to a tm struct |
Format Conversion | _localtime32 | time.h | No | No | No | Yes | No | No | Convert a time32_t to a tm struct, adjusting for time zone |
Format Conversion | _localtime32 | time.h | No | No | No | Yes | No | No | Version of localtime for 32-bit time_t |
Format Conversion | _localtime32_s | time.h | No | No | No | Yes | No | No | Convert a time32_t to a tm struct, adjusting for time zone |
Format Conversion | _localtime64 | time.h | No | No | No | Yes | No | No | Convert a time64_t to a tm struct, adjusting for time zone |
Format Conversion | _localtime64 | time.h | No | No | No | Yes | No | No | Version of localtime for 64-bit time_t (valid until Dec 31, 3000) |
Format Conversion | _localtime64_s | time.h | No | No | No | Yes | No | No | Convert a time64_t to a tm struct, adjusting for time zone |
Format Conversion | _mkgmtime | time.h | No | No | No | Yes | No | No | Convert a UTC time in a tm struct to a UTC time in a time_t |
Format Conversion | _mkgmtime32 | time.h | No | No | No | Yes | No | No | Convert a UTC time in a tm struct to a UTC time in a time32_t |
Format Conversion | _mkgmtime64 | time.h | No | No | No | Yes | No | No | Convert a UTC time in a tm struct to a UTC time in a time64_t |
Format Conversion | _mktime32 | time.h | No | No | No | Yes | No | No | Convert a local time in tm struct to a time32_t |
Format Conversion | _mktime64 | time.h | No | No | No | Yes | No | No | Convert a local time in tm struct to a time64_t |
Format Conversion | _strdate | time.h | No | No | No | Yes | No | No | Copies the current system date to a buffer in format DD/MM/YY |
Format Conversion | _strdate_s | time.h | No | No | No | Yes | No | No | Copies the current system date to a buffer in format DD/MM/YY |
Format Conversion | _strftime_l | time.h | No | No | No | Yes | No | No | Convert a time in a tm struct to a string using a specified format and locale |
Format Conversion | _strtime | time.h | No | No | No | Yes | No | No | Copied the current system time to a buffer in format HH:MM:SS |
Format Conversion | _strtime_s | time.h | No | No | No | Yes | No | No | Copied the current system time to a buffer in format HH:MM:SS |
Format Conversion | _tstrdate | tchar.h | No | No | No | Yes | No | No | Same as _wstrdate |
Format Conversion | _tstrdate_s | tchar.h | No | No | No | Yes | No | No | Same as _wstrdate_s |
Format Conversion | _tstrtime | tchar.h | No | No | No | Yes | No | No | Same as _wstrtime |
Format Conversion | _tstrtime_s | tchar.h | No | No | No | Yes | No | No | Same as _wstrtime_s |
Format Conversion | _wasctime_s | time.h | No | No | No | Yes | No | No | Convert a tm struct to a string |
Format Conversion | _wcsftime_l | wchar.h | No | No | No | Yes | No | No | Convert time in tm struct to wide char string using a specified format and locale |
Format Conversion | _wctime | time.h or wchar.h | No | No | No | Yes | No | No | Convert a time_t to a wide date/time string |
Format Conversion | _wctime_s | time.h or wchar.h | No | No | No | Yes | No | No | Convert a time_t to a wide date/time string |
Format Conversion | _wctime32 | time.h or wchar.h | No | No | No | Yes | No | No | Convert a time32_t to a wide date/time string |
Format Conversion | _wctime32_s | time.h or wchar.h | No | No | No | Yes | No | No | Convert a time32_t to a wide date/time string |
Format Conversion | _wctime64 | time.h or wchar.h | No | No | No | Yes | No | No | Convert a time64_t to a wide date/time string |
Format Conversion | _wctime64_s | time.h or wchar.h | No | No | No | Yes | No | No | Convert a time64_t to a wide date/time string |
Format Conversion | _wstrdate | time.h | No | No | No | Yes | No | No | The wide-character version of _strdate |
Format Conversion | _wstrdate_s | time.h | No | No | No | Yes | No | No | The wide-character version of _strdate_s |
Format Conversion | _wstrtime | time.h | No | No | No | Yes | No | No | The wide-character version of _strtime |
Format Conversion | _wstrtime_s | time.h | No | No | No | Yes | No | No | The wide-character version of _strtime_s |
Format Conversion | asctime | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Convert a date/time in a tm struct to a string |
Format Conversion | asctime_r | time.h | No | Yes | Yes | No | Yes | Yes | Convert a date/time in a tm struct to a string |
Format Conversion | asctime_s | time.h | Yes | No | No | Yes | Yes | No | Convert a tm struct to a string |
Format Conversion | ctime | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Convert a time_t to a date/time string |
Format Conversion | ctime_r | time.h | No | Yes | Yes | No | Yes | Yes | Convert a time_t to a date/time string |
Format Conversion | ctime_s | time.h | Yes | No | No | Yes | No | No | Convert a time_t to a date/time string |
Format Conversion | DosDateTimeToFileTime | Windows.h | No | No | No | Yes | No | No | Convert MSDOS date/time to FILETIME |
Format Conversion | ExLocalTimeToSystemTime | Wdm.h | No | No | No | Yes | No | No | Convert system time for current time zone to unbiased GMT |
Format Conversion | ExSystemTimeToLocalTime | Wdm.h | No | No | No | Yes | No | No | Convert GMT system time to local system time for current time zone |
Format Conversion | FileTimeToDosDateTime | Windows.h | No | No | No | Yes | No | No | Convert FILETIME to MSDOS date/time |
Format Conversion | FileTimeToLocalFileTime | Windows.h | No | No | No | Yes | No | No | Convert a UTC-based FILETIME to a local time-based FILETIME |
Format Conversion | FileTimeToSystemTime | Windows.h | No | No | No | Yes | No | No | Convert a FILETIME to a SYSTEMTIME (broken out, UTC-based) |
Format Conversion | getdate | time.h | No | Yes | Yes | No | Yes | No | Converts date/time string to struct tm |
Format Conversion | getdate_r | time.h | No | No | Yes | No | No | No | GNU re-entrant version of getdate |
Format Conversion | gmtime | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Convert a time_t to a tm struct |
Format Conversion | gmtime_r | time.h | No | Yes | Yes | No | Yes | Yes | Convert a time_t to a tm struct |
Format Conversion | gmtime_s | time.h | Yes | No | No | Yes | No | No | Convert a time_t to a tm struct |
Format Conversion | LocalFileTimeToFileTime | Windows.h | No | No | No | Yes | No | No | Convert a local FILETIME to a FILETIME based on UTC |
Format Conversion | localtime | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Convert a time_t to a tm struct, adjusting for time zone |
Format Conversion | localtime_r | time.h | No | Yes | Yes | No | Yes | Yes | Convert a time_t to a tm struct, adjusting for time zone |
Format Conversion | localtime_s | time.h | Yes | No | No | Yes | No | No | Convert a time_t to a tm struct, adjusting for time zone |
Format Conversion | mktime | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Convert a local time in tm struct to a time_t |
Format Conversion | RtlLocalTimeToSystemTime | Windows.h | No | No | No | Yes | No | No | Convert local time in LARGE_INTEGER to system time in LARGE_INTEGER |
Format Conversion | RtlTimeToSecondsSince1970 | Windows.h | No | No | No | Yes | No | No | Convert system time in LARGE_INTEGER to # seconds since 1970 in ULONG |
Format Conversion | strftime | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Convert a time in a tm struct to a string using a specified format |
Format Conversion | strftime_l | time.h | No | No | No | No | Yes | No | Convert a time in a tm struct to a string using a specified format and locale |
Format Conversion | strptime | time.h | No | Yes | Yes | No | Yes | No | Convert a string containing date/time to a tm struct using a given format |
Format Conversion | strptime_l | time.h | No | No | No | No | Yes | No | Convert a string containing date/time to a tm struct using a given format and locale |
Format Conversion | SystemTimeToFileTime | Windows.h | No | No | No | Yes | No | No | Convert time in a SYSTEMTIME struct (in UTC) to a FILETIME |
Format Conversion | SystemTimeToTzSpecificLocalTime | Windows.h | No | No | No | Yes | No | No | Convert UTC tie in SYSTEMTIME struct to SYSTEMTIME in specified time zone |
Format Conversion | SystemTimeToTzSpecificLocalTimeEx | Windows.h | No | No | No | Yes | No | No | Convert UTC tie in SYSTEMTIME struct to SYSTEMTIME in specified time zone |
Format Conversion | timegm | time.h | No | No | Yes | No | Yes | No | Convert a UTC-based time in tm struct to a time_t |
Format Conversion | timelocal | time.h | No | No | Yes | No | Yes | No | Convert a local time in tm struct to a time_t (Equivalent of mktime) |
Format Conversion | TzSpecificLocalTimeToSystemTime | Windows.h | No | No | No | Yes | No | No | Convert a local time in SYSTEMTIME to a UTC time also in SYSTEMTIME |
Format Conversion | TzSpecificLocalTimeToSystemTimeEx | Windows.h | No | No | No | Yes | No | No | Convert a local time in SYSTEMTIME to a UTC time also in SYSTEMTIME |
Format Conversion | wcsftime | wchar.h | Yes | Yes | Yes | Yes | Yes | No | Convert a time in a tm struct to a wide char string using a specified format |
Global Variable | daylight | time.h | No | Yes | Yes | Yes | Yes | No | Set to 0 to disable DST conversions |
Global Variable | timezone | time.h | No | Yes | Yes | Yes | Yes | No | The difference in seconds between UTC and local standard time |
Global Variable | tzname[0] | time.h | No | Yes | Yes | Yes | Yes | No | The string for local standard time (without DST), e.g. "EST" |
Global Variable | tzname[1] | time.h | No | Yes | Yes | Yes | Yes | No | The string for local daylight time (with DST), e.g. "EDT" |
Macro | __DATE__ | N/A | Yes | No | Yes | Yes | Yes | Yes | String of the current date in the form "Mmm dd yyyy" |
Macro | __TIME__ | N/A | Yes | No | Yes | Yes | Yes | Yes | String of the current time in the form "hh:mm:ss" |
Macro | LC_TIME | locale.h | Yes | Yes | Yes | Yes | Yes | Yes | Used for formatting date and time values with strftime |
Msg Queue | mq_timedreceive | mqueue.h | No | Yes | Yes | No | No | Yes | Rcv a msg from a msg queue, wait max of absolute time in timespec struct |
Msg Queue | mq_timedsend | mqueue.h | No | Yes | Yes | No | No | Yes | Send a msg from a msg queue, wait max of absolute time in timespec struct |
Simple Type | __darwin_suseconds_t | sys/_types.h | No | No | No | No | Yes | No | A 32-bit signed integer representing usecs |
Simple Type | __darwin_time_t | i386/_types.h | No | No | No | No | Yes | No | Apple's time_t (defined as 'long') |
Simple Type | __darwin_useconds_t | sys/_types.h | No | No | No | No | Yes | No | A 32-bit unsigned integer representing usecs |
Simple Type | __int64 | varies | No | No | Yes | Yes | Yes | No | A signed 64-bit signed integer |
Simple Type | __suseconds_t | bits/types.h | No | No | Yes | No | No | No | A 32-bit signed integer representing usecs |
Simple Type | __time32_t | time.h | No | No | No | Yes | No | No | A 32-bit signed integer (defined as long which is 32-bits on Windows) |
Simple Type | __time64_t | time.h | No | No | No | Yes | No | No | A 64-bit signed integer (defined as __int64) |
Simple Type | __useconds_t | bits/types.h | No | No | Yes | No | No | No | A 32-bit unsigned integer representing usecs |
Simple Type | clock_res_t | mach/clock_types.h | No | No | No | No | Yes | No | Defined as int |
Simple Type | clock_t | Varies | Yes | Yes | Yes | Yes | Yes | Yes | long on Linux and Windows, unsigned long on OSX, and unsigned int on VxWorks |
Simple Type | DWORD | Varies | No | No | Yes | Yes | Yes | Yes | A 32-bit unsigned integer |
Simple Type | INT | Several | No | No | No | Yes | No | No | Same as int |
Simple Type | int | n/a | Yes | Yes | Yes | Yes | Yes | Yes | A signed integer; check platform for actual size |
Simple Type | LONG | Several | No | No | No | Yes | No | Yes | Same as long (32-bits on all Windows) |
Simple Type | long | n/a | Yes | Yes | Yes | Yes | Yes | Yes | A signed integer; check platform for actual size |
Simple Type | long long | n/a | Yes | Yes | Yes | Yes | Yes | Yes | A signed 64-bit integer |
Simple Type | LONGLONG | Several | No | No | No | Yes | No | Yes | Same as long long (64-bits) |
Simple Type | size_t | stddef.h | Yes | Yes | Yes | Yes | Yes | Yes | Defined as unsigned int on VxWorks |
Simple Type | suseconds_t | sys/types.h | No | Yes | Yes | No | Yes | No | A 32-bit signed integer representing usecs |
Simple Type | time_t | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Secs since epoch; long on Linux and OSX, __time32_t or __time64_t on Windows, unsigned long on VxWorks for 32-bit systems |
Simple Type | UINT | Several | No | No | No | Yes | No | No | Same as unsigned int |
Simple Type | ULONG | Several | No | No | No | Yes | No | Yes | Same as unsigned long (32-bits on all Windows) |
Simple Type | ULONGLONG | Several | No | No | No | Yes | No | Yes | Same as unsigned long long (64-bits) |
Simple Type | unsigned int | n/a | Yes | Yes | Yes | Yes | Yes | Yes | An unsigned integer; check platform for actual size |
Simple Type | unsigned long | n/a | Yes | Yes | Yes | Yes | Yes | Yes | An unsigned integer; check platform for actual size |
Simple Type | unsigned long long | n/a | Yes | Yes | Yes | Yes | Yes | Yes | An unsigned 64-bit integer |
Simple Type | useconds_t | sys/types.h | No | Yes | Yes | No | Yes | No | A 32-bit unsigned integer representing usecs |
Sleep Func | _sleep | stdlib.h | No | No | No | Yes | No | No | Sleep for given # of (units unknown), in unsigned long |
Sleep Func | _Thrd_sleep | thr/xthreads.h | No | No | No | Yes | No | No | Sleep unti an absolute time given in an xtime |
Sleep Func | clock_nanosleep | time.h | No | Yes | Yes | No | No | Yes | Sleep until an absolute time or relative time given in a timespec struct |
Sleep Func | nanosleep | time.h | No | Yes | Yes | No | Yes | Yes | Sleep for given # of nanoseconds given in a timespec struct |
Sleep Func | sleep | unistd.h | No | Yes | Yes | No | Yes | Yes | Sleep for given # of seconds in unsigned int |
Sleep Func | sleep | thr/thread | No | No | No | Yes | No | No | Sleep until the absolute time given in an xtime |
Sleep Func | Sleep | Windows.h | No | No | No | Yes | No | No | Sleep for given # of msecs in a DWORD |
Sleep Func | sleep_for | thread | No | No | No | Yes | No | No | Sleep until a relative time |
Sleep Func | sleep_until | thread | No | No | No | Yes | No | No | Sleep until an absolute time |
Sleep Func | thrd_sleep | thr/threads.h | Yes | No | No | Yes | No | No | Sleep until an absolute time given in an xtime |
Sleep Func | usleep | unistd.h | No | No* | Yes | No | Yes | No | Sleep for given # of usecs, in a useconds_t |
Structure | DYNAMIC_TIME_ZONE_INFORMATION | Windows.h | No | No | No | Yes | No | No | Specifies settings for a time zone and dynamic daylight saving time |
Structure | FILETIME | Windows.h | No | No | No | Yes | No | No | Contains 2 DWORDs for time since Jan 1, 1601 in units of 100 nsecs |
Structure | LARGE_INTEGER | Wtypes.Idl | No | No | No | Yes | No | No | A union containing 'LONGLONG QuadPart' (64-bit signed integer), etc |
Structure | mach_timespec_t | mach/clock_types.h | No | No | No | No | Yes | No | Contains unsigned int for seconds and (signed) int for nsecs |
Structure | MMTIME | Windows.h | No | No | No | Yes | No | No | Contains timing information on various types of multimedia data |
Structure | struct __stat64 | sys/stat.h | No | No | No | Yes | No | No | Same as _stat64 |
Structure | struct __timeb32 | sys/timeb.h | No | No | No | Yes | No | No | Contains __time32_t for time in secs, unsigned short for msecs |
Structure | struct __timeb64 | sys/timeb.h | No | No | No | Yes | No | No | Contains __time64_t for time in secs, unsigned short for msecs |
Structure | struct __utimbuf32 | sys/utime.h | No | No | No | Yes | No | No | Contains __time32_t for access and modification times |
Structure | struct __utimbuf64 | sys/utime.h | No | No | No | Yes | No | No | Contains __time64_t for access and modification times |
Structure | struct _stat | sys/stat.h | No | No | No | Yes | No | No | Defined as _stat32 or _stat64i32 depending on _USE_32BIT_TIME_T |
Structure | struct _stat32 | sys/stat.h | No | No | No | Yes | No | No | Contains __time32_t for st_atime, st_mtime, and st_ctime |
Structure | struct _stat32i64 | sys/stat.h | No | No | No | Yes | No | No | Contains __time32_t for st_atime, st_mtime, and st_ctime |
Structure | struct _stat64i32 | sys/stat.h | No | No | No | Yes | No | No | Defined as _stat32i64 or _stat64 depending on _USE_32BIT_TIME_T |
Structure | struct _stati64 | sys/stat.h | No | No | No | Yes | No | No | Contains __time64_t for st_atime, st_mtime, and st_ctime |
Structure | struct _timeb | sys/timeb.h | No | No | No | Yes | No | No | Defined as __timeb32 or __timeb64 depending on _USE32BIT_TIME_T |
Structure | struct _utimbuf | sys/utime.h | No | No | No | Yes | No | No | Contains time_t for access and modification times |
Structure | struct itimerspec | time.h | No | Yes | Yes | No | No | Yes | Contains timespec structs for timer period and expiration |
Structure | struct itimerval | sys/time.h | No | Yes | Yes | No | Yes | No | Contains timeval structs for timer period and expiration |
Structure | struct mach_timespec | mach/clock_types.h | No | No | No | No | Yes | No | Contains unsigned int for seconds and clock_res_t for nsecs |
Structure | struct rusage | sys/resource.h | No | Yes | Yes | No | Yes | No | Contains timeval structs for user and system time used |
Structure | struct stat | sys/stat.h | No | Yes | Yes | Yes | Yes | Yes | Contains fields for access, modification, and creation times |
Structure | struct stat64 | sys/stat.h | No | No | Yes | No | Yes | No | Same as stat structure |
Structure | struct timeb | sys/timeb.h | No | Yes | Yes | Yes | Yes | No | Contains time_t for time in secs, unsigned short for msecs |
Structure | struct timespec | time.h | Yes | Yes | Yes | No | Yes | Yes | Contains fields for seconds and nsecs, time_t for secs, long for nsecs |
Structure | struct timeval | sys/time.h | No | Yes | Yes | Yes | Yes | Yes | Contains fields for seconds and usecs, types vary slightly per platform |
Structure | struct tm | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Contains broken out date/time fields each of type int |
Structure | struct tms | sys/times.h | No | Yes | Yes | No | Yes | No | Contains clock_t for process times (user & system for current & children) |
Structure | struct utimbuf | sys/utime.h | No | Yes | Yes | Yes | No | No | Contains time_t for access and modification times |
Structure | struct utimbuf32 | sys/utime.h | No | No | No | Yes | No | No | Contains __time32_t for access and modification times |
Structure | SYSTEMTIME | Windows.h | No | No | No | Yes | No | No | Specifies a date and time in UTC or local time |
Structure | TIME_FIELDS | n/a | No | No | No | Yes | No | No | Undocumented Windows struct |
Structure | TIME_ZONE_INFORMATION | Windows.h | No | No | No | Yes | No | No | Specifies settings for a time zone |
Structure | TIMECAPS | Windows.h | No | No | No | Yes | No | No | Contains timer resolution in min/max msecs in UINT |
Structure | ULARGE_INTEGER | Wtypes.Idl | No | No | No | Yes | No | No | A union containing 'ULONGLONG QuadPart' (64-bit unsigned integer), etc. |
Structure | WIN32_FILE_ATTRIBUTE_DATA | Windows.h | No | No | No | Yes | No | No | Returned by GetFileAttributesEx, contains FILETIMEs for a file |
Structure | xtime | thr/xtimec.h | No | No | No | Yes | No | No | Contains time_t for seconds and long for nsecs. |
System Clock | clock_get_res | mach/mach.h | No | No | No | No | Yes | No | OSX version of clock_getres |
System Clock | clock_get_time | mach/clock.h | No | No | No | No | Yes | No | OSX version of clock_gettime |
System Clock | clock_getres | time.h | No | Yes | Yes | No | No | Yes | Gets the resolution of a clock to the value in a timespec |
System Clock | clock_gettime | time.h | No | Yes | Yes | No | No | Yes | Gets the current value of a clock in a timespec |
System Clock | clock_set_res | mach/mach.h | No | No | No | No | Yes | No | OSX version of clock_setres |
System Clock | clock_set_time | mach/clock_priv.h | No | No | No | No | Yes | No | OSX version of clock_settime |
System Clock | clock_setres | time.h | No | No | No | No | No | Yes | Sets the resolution of a clock to the value in a timespec |
System Clock | clock_settime | time.h | No | Yes | Yes | No | No | Yes | Sets the current value of a clock in a timespec |
System Clock | sysAuxClkConnect | sysLib.h | No | No | No | No | No | Yes | Connect callback func to aux clock |
System Clock | sysAuxClkDisable | sysLib.h | No | No | No | No | No | Yes | Disable aux clock interrupt |
System Clock | sysAuxClkEnable | sysLib.h | No | No | No | No | No | Yes | Enable aux clock interrupt |
System Clock | sysAuxClkRateGet | sysLib.h | No | No | No | No | No | Yes | Get the aux clock rate |
System Clock | sysAuxClkRateSet | sysLib.h | No | No | No | No | No | Yes | Set the aux clock rate |
System Clock | sysClkConnect | sysLib.h | No | No | No | No | No | Yes | Connect callback func to system clock |
System Clock | sysClkDisable | sysLib.h | No | No | No | No | No | Yes | Disable the system clock |
System Clock | sysClkEnable | sysLib.h | No | No | No | No | No | Yes | Enable the system clock |
System Clock | sysClkRateGet | sysLib.h | No | No | No | No | No | Yes | Get the system clock rate |
System Clock | sysClkRateSet | sysLib.h | No | No | No | No | No | Yes | Set the system clock rate |
Time Calculation | _difftime32 | time.h | No | No | No | Yes | No | No | Version of difftime for 32-bit time_t |
Time Calculation | _difftime64 | time.h | No | No | No | Yes | No | No | Version of difftime for 64-bit time_t |
Time Calculation | CompareFileTime | Windows.h | No | No | No | Yes | No | No | Compares two FILETIMEs |
Time Calculation | difftime | time.h | Yes | Yes | Yes | Yes | Yes | Yes | Calculates the difference between two time_t values |
Time Calculation | timersub | sys/time.h | No | No | Yes | No | Yes | No | Calculates the difference between two timeval values |
Timer/Alarm | alarm | unistd.h | No | Yes | Yes | No | Yes | Yes | Schedules an alarm signal |
Timer/Alarm | getitimer | sys/time.h | No | Yes* | Yes | No | Yes | No | Gets value of an interval timer in an itimerval struct |
Timer/Alarm | KillTimer | WinUser.h | No | No | No | No | No | Yes | Kill a Windows timer |
Timer/Alarm | setitimer | sys/time.h | No | Yes* | Yes | No | Yes | No | Sets an interval timer to the value in an itimerval struct |
Timer/Alarm | SetTimer | WinUser.h | No | No | No | No | No | Yes | Set up a Windows timer |
Timer/Alarm | timer_cancel | timers.h | No | No | No | No | No | Yes | Cancel a timer |
Timer/Alarm | timer_connect | timers.h | No | No | No | No | No | Yes | Connect a callback function to a timer signal |
Timer/Alarm | timer_create | time.h | No | Yes | Yes | No | No | Yes | Create a (per process, real-time) timer |
Timer/Alarm | timer_delete | time.h | No | Yes | Yes | No | No | Yes | Delete a (per process, real-time) timer |
Timer/Alarm | timer_getoverrun | sys/timerfd.h | No | Yes | Yes | No | No | Yes | Gets # of expirations since the signal was generated |
Timer/Alarm | timer_gettime | time.h | No | Yes | Yes | No | No | Yes | Gets time before expiration and interval, times use itimerspec struct |
Timer/Alarm | timer_settime | time.h | No | Yes | Yes | No | No | Yes | Sets time until next expiration, times use itimerspec structs |
Timer/Alarm | timerfd_create | sys/timerfd.h | No | No | Yes | No | No | No | Create a timer based on a file descriptor |
Timer/Alarm | timerfd_gettime | sys/timerfd.h | No | No | Yes | No | No | No | Gets current settings for a file descriptor, time is in itimerspec struct |
Timer/Alarm | timerfd_settime | sys/timerfd.h | No | No | Yes | No | No | No | Starts or stops a timer for a file descriptor, times are in itimerspec structs |
Timer/Alarm | ualarm | unistd.h | No | No* | Yes | No | Yes | No | Schedules a signal after given number of usecs in useconds_t |
Timezone | _get_daylight | time.h | No | No | No | Yes | No | No | Retrieves _daylight environment variable |
Timezone | _get_dstbias | time.h | No | No | No | Yes | No | No | Retrieves _dstbias environment variable |
Timezone | _get_timezone | time.h | No | No | No | Yes | No | No | Retrieves _timezone environment variable |
Timezone | _get_tzname | time.h | No | No | No | Yes | No | No | Retrieves _tzname environment variable |
Timezone | _tzset | time.h | No | No | No | Yes | No | No | Sets time-related environment variables |
Timezone | timezone | time.h | No | No | No | No | Yes | No | Returns the timezone abbreviation |
Timezone | tzset | time.h | No | Yes | Yes | Yes | Yes | No | Sets time-related environment variables |
Timezone | tzsetwall | time.h | No | No | No | No | Yes | No | Helps localtime return best approx of local wall clock time |
Windows Interrupt Time | QueryInterruptTime | Realtimeapiset.h | No | No | No | Yes | No | No | Gets current 'interrupt time' in units of 100 nsecs, including sleep time |
Windows Interrupt Time | QueryInterruptTimePrecise | Realtimeapiset.h | No | No | No | Yes | No | No | Gets current 'interrupt time' in units of 100 nsecs, including sleep time |
Windows Interrupt Time | QueryUnbiasedInterruptTime | Realtimeapiset.h | No | No | No | Yes | No | No | Gets current 'interrupt time' in units of 100 nsecs, not including sleep time |
Windows Interrupt Time | QueryUnbiasedInterruptTimePrecise | Realtimeapiset.h | No | No | No | Yes | No | No | Gets current 'interrupt time' in units of 100 nsecs, not including sleep time |
Windows MM Timer | timeBeginPeriod | Windows.h | No | No | No | Yes | No | No | requests a minimum resolution for periodic timers |
Windows MM Timer | timeEndPeriod | Windows.h | No | No | No | Yes | No | No | Clears a previously set minimum timer resolution |
Windows MM Timer | timeGetDevCaps | Windows.h | No | No | No | Yes | No | No | Queries timer device to get resolution, resolution, in TIMECAPS struct |
Windows MM Timer | timeGetSystemTime | Windows.h | No | No | No | Yes | No | No | Gets the time since the system started in msecs, returned as an MMTIME |
Windows MM Timer | timeGetTime | Windows.h | No | No | No | Yes | No | No | Gets the time since the system started in msecs, returned as a DWORD |
Windows MM Timer | timeKillEvent | Windows.h | No | No | No | Yes | No | No | Cancels a timer event |
Windows MM Timer | TimeProc | Windows.h | No | No | No | Yes | No | No | Function called at expiration of event(s) |
Windows MM Timer | timeSetEvent | Windows.h | No | No | No | Yes | No | No | Configures a function called after a delay and resolution in msecs in UINT |
Windows Perf Counter | KeQueryInterruptTime | Wdm.h | No | No | No | Yes | No | No | Gets interrupt time count in 100 nsec in LONGLONG |
Windows Perf Counter | KeQueryPerformanceCounter | Wdm.h | No | No | No | Yes | No | No | Gets current value of performance counter and freq in LARGE_INTEGERs |
Windows Perf Counter | KeQuerySystemTime | Wdm.h | No | No | No | Yes | No | No | Gets system time in 100 sec increments since Jan 1, 1601 in LARGE_INTEGER |
Windows Perf Counter | KeQueryTickCount | Wdm.h | No | No | No | Yes | No | No | Gets # of interval timer interrupts since system booted in LARGE_INTEGER |
Windows Perf Counter | KeQueryTimeIncrement | Wdm.h | No | No | No | Yes | No | No | Gets # of 100 nsecs added to system time on each clock interrupt in LONG |
Windows Perf Counter | QueryPerformanceCounter | Windows.h | No | No | No | Yes | No | No | Gets current value of performance counter in LARGE_INTEGER |
Windows Perf Counter | QueryPerformanceFrequency | Windows.h | No | No | No | Yes | No | No | Gets performance counter frequency (counts per sec) in LARGE_INTEGER |
Windows Timer | CreateWaitableTimer | Windows.h | No | No | No | Yes | No | No | Creates or opens a waitable timer object |
Windows Timer | SetWaitableTimer | Windows.h | No | No | No | Yes | No | No | Activates a timer, DueTime is UTC since Jan 1, 1601 in LARGE_INTEGER, period in msecs |
Windows Timer | SetWaitableTimerEx | Windows.h | No | No | No | Yes | No | No | Activates a timer, DueTime is UTC since Jan 1, 1601 in LARGE_INTEGER, period in LONG in msecs, also has TolerableDelay in msecs as ULONG |
Windows Timer | WaitForSingleObject | Windows.h | No | No | No | Yes | No | No | Wait for an object to be in signaled state or time-out |
Windows Undoc | NtGetTickCount | n/a | No | No | No | Yes | No | No | Returns system timer's tick count as ULONG |
Windows Undoc | NtQueryPerformanceCounter | n/a | No | No | No | Yes | No | No | Returns # processor ticks and frequency as LARGE_INTEGERs |
Windows Undoc | NtQuerySystemTime | n/a | No | No | No | Yes | No | No | Returns current time in UTC format in units of 100 nsecs since Jan 1, 1600 |
Windows Undoc | NtQueryTimerResolution | n/a | No | No | No | Yes | No | No | Gets min, max, and actual timer resolution in 100 nsec units as ULONG |
Windows Undoc | NtSetSystemTime | n/a | No | No | No | Yes | No | No | Sets system time to given UTC format as LARGE_INTEGER |
Windows Undoc | NtSetTimerResolution | n/a | No | No | No | Yes | No | No | Requests a timer resolution in 100 nsec units as ULONG |
Windows Undoc | RtlTimeFieldsToTime | n/a | No | No | No | Yes | No | No | Converts TIME_FIELDS struct to time in LARGE_INTEGER |
Windows Undoc | RtlTimeToTimeFields | n/a | No | No | No | Yes | No | No | Converts time in LARGE_INTEGER to TIME_FIELDS struct |
Windows 'xtime' | _Xtime_diff_to_millis | thr/xtimec.h | No | No | No | Yes | No | No | Returns diff between 2 xtime structs, returned as long in msecs |
Windows 'xtime' | _Xtime_diff_to_millis2 | thr/xtimec.h | No | No | No | Yes | No | No | Returns diff between current time and xtime struct, returns long in msecs |
Windows 'xtime' | _Xtime_get_ticks | thr/xtimec.h | No | No | No | Yes | No | No | Get system time in 100 nsec intervals since the epoch, returned in xtime |
Windows 'xtime' | xtime_get | thr/xtimec.h | No | No | No | Yes | No | No | Get the current time returned in an xtime struct |