wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/Time/GetTimeStr

Version 9 (modified by Don Wilson, 4 years ago) ( diff )

--

GetTimeStr

Get the time

string GetTimeStr(int secs);

char* GetTimeStr(char* pszBuffer, int secs);

string GetTimeStr(datetime_struct* pTime, int secs);

char* GetTimeStr(datetime_struct* pTime, char* pszBuffer, int secs);

Parameters

  • secs - 0 = format time without secs, 1 = include seconds
  • pszBuffer - buffer to hold formatted time, application programmer must insure that this buffer is large enough for the time.
  • pTime - pointer to datetime_struct to format the time from instead of current time.

Return Value

  • Returns the time formatted as "HH:MM:SS" or "HH-MM-SS", or "HH:MM x.m.", based on boot loader preferences. Application developers should consider that time string will be longer if preferences are set for 12 hour time. The versions of the function that take a pointer to a datetime_struct allow a string to be formatted from an arbitrary time.

Remarks

Versions of this function that are not passed a pointer to a datetime_struct return the time information that is in memory based on a previous call to GetLinuxTime() or IsTimeChanged().

Examples

string strTime = GetTimeStr(1);
DisplayText(10, 10, strTime);
char szTime[20];
GetTimeStr(szTime, 1);
DisplayText(10, 10, szTime);
datetime_struct dt;
dt.hour = 9;
dt.minute = 21;
dt.second = 30;

string strTime = GetTimeStr(&dt, 1);
DisplayText(10, 10, strTime);
datetime_struct dt;
dt.hour = 9;
dt.minute = 21;
dt.second = 30;

char szTime[20];

GetTimeStr(&dt, szTime, 1);
DisplayText(10, 10, szTime);

See Also

Note: See TracWiki for help on using the wiki.