tfGetUtcTime
Table of Contents >> Programmer's Reference
| #include <trsocket.h> |
| int tfGetUtcTime | ( |
| ttUser32Bit days, | |
| ttUser32Bit seconds, | |
| ttTimeCalPtr timePtr | |
| ); |
Function Description
This is a utility function that takes as input the number of days and/or seconds since midnight, January 1, 1970 and returns as output the following user-friendly time/date structure.
This function is similar to the Unix® gmtime() function. If you want to convert to localtime() (or any timezone), merely add or subtract the the timezone difference from UTC in seconds before calling tfGetUtcTime().
The ttTimeCal Structure
#include <trsocket.h> /* * Time/date structure. */ typedef struct tsTimeCal { int tmcMsec; /* milliseconds after the second - [0,999] */ int tmcSec; /* seconds after the minute - [0,59] */ int tmcMin; /* minutes after the hour - [0,59] */ int tmcHour; /* hours since midnight - [0,23] */ int tmcMday; /* day of the month - [1,31] */ int tmcMon; /* months since January - [0,11] */ int tmcYear; /* years since 1900 */ int tmcWday; /* days since Sunday - [0,6] */ int tmcYday; /* days since January 1 - [0,365] */ } ttTimeCal; typedef ttTimeCal TM_FAR * ttTimeCalPtr;
Parameters
- days
- The number of days elapsed since midnight (00:00:00), January 1, 1970, Coordinated Universal Time (UTC). You may specify 0 for days if seconds accounts for the full elapsed time.
- seconds
- The number of seconds elapsed since midnight (00:00:00), January 1, 1970, Coordinated Universal Time (UTC). The total elapsed time is derived from the sum of this value and the days parameter.
- timePtr
- A pointer to a ttTimeCal variable where the converted time/date is to be stored.
Returns
- TM_ENOERROR
- Success.
- TM_EINVAL
- timePtr is NULL or arithmetic overflow occurred.