le_clock.h File Reference
Go to the source code of this file.
Data Structures | |
struct | le_clk_Time_t |
Macros | |
String Formats | |
Pre-defined formats for converting time to string format. These pre-defined formats use the conversion specifiers from strftime(). | |
#define | LE_CLK_STRING_FORMAT_DATE_TIME "%c" |
Preferred date and time format for current locale, e.g. "Mon Jan 21 13:37:05 2013". | |
#define | LE_CLK_STRING_FORMAT_DATE "%x" |
Preferred date format for current locale, e.g. "01/21/13". | |
#define | LE_CLK_STRING_FORMAT_TIME "%X" |
Preferred time format for current locale, e.g. "13:37:05". | |
Functions | |
le_clk_Time_t | le_clk_GetRelativeTime (void) |
le_clk_Time_t | le_clk_GetAbsoluteTime (void) |
le_clk_Time_t | le_clk_Add (le_clk_Time_t timeA, le_clk_Time_t timeB) |
bool | le_clk_GreaterThan (le_clk_Time_t timeA, le_clk_Time_t timeB) |
bool | le_clk_Equal (le_clk_Time_t timeA, le_clk_Time_t timeB) |
le_clk_Time_t | le_clk_Sub (le_clk_Time_t timeA, le_clk_Time_t timeB) |
le_clk_Time_t | le_clk_Multiply (le_clk_Time_t timeA, int scaleFactor) |
le_result_t | le_clk_GetUTCDateTimeString (const char *formatSpecStrPtr, char *destStrPtr, size_t destSize, size_t *numBytesPtr) |
le_result_t | le_clk_GetLocalDateTimeString (const char *formatSpecStrPtr, char *destStrPtr, size_t destSize, size_t *numBytesPtr) |
le_result_t | le_clk_ConvertToUTCString (le_clk_Time_t time, const char *formatSpecStrPtr, char *destStrPtr, size_t destSize, size_t *numBytesPtr) |
le_result_t | le_clk_ConvertToLocalTimeString (le_clk_Time_t time, const char *formatSpecStrPtr, char *destStrPtr, size_t destSize, size_t *numBytesPtr) |
le_result_t | le_clk_SetAbsoluteTime (le_clk_Time_t absoluteTime) |
LE_FULL_API le_result_t | le_clk_ConvertToTime (const char *formatSpecStrPtr, const char *srcStrPtr, le_clk_Time_t *timePtr) |
LE_FULL_API le_result_t | le_clk_SetUTCDateTimeString (const char *formatSpecStrPtr, const char *srcStrPtr) |
le_result_t | le_clk_SetTimezoneFile (const int32_t timezoneOffsetSeconds, const uint8_t dstOffsetHours) |
Detailed Description
Legato System Clock API include file.
Copyright (C) Sierra Wireless Inc.
Function Documentation
◆ le_clk_Add()
le_clk_Time_t le_clk_Add | ( | le_clk_Time_t | timeA, |
le_clk_Time_t | timeB | ||
) |
Add two time values together, and return the result.
- Returns
- Sum of the two time values
◆ le_clk_ConvertToLocalTimeString()
le_result_t le_clk_ConvertToLocalTimeString | ( | le_clk_Time_t | time, |
const char * | formatSpecStrPtr, | ||
char * | destStrPtr, | ||
size_t | destSize, | ||
size_t * | numBytesPtr | ||
) |
Generate a printable string representation of a given absolute date/time value as a local time (with timezone offset applied).
The formatted date/time string, including NULL-terminator, will be copied to the destination buffer, provided it fits, and the number of bytes copied (not including the NULL-terminator) will be returned in numBytesPtr.
If the formatted date/time string does not fit in the destination buffer, then the contents of the destination buffer are undefined, and the value returned in numBytesPtr is zero.
- Returns
- LE_OK if the formatted string was copied to destStrPtr
- LE_OVERFLOW if the formatted string would not fit in destStrPtr
- Parameters
-
[in] time date/time to convert [in] formatSpecStrPtr Format specifier string, using conversion specifiers defined for strftime(). [out] destStrPtr Destination for the formatted date/time string [in] destSize Size of the destination buffer in bytes. [out] numBytesPtr Number of bytes copied, not including NULL-terminator. Parameter can be set to NULL if the number of bytes copied is not needed.
◆ le_clk_ConvertToTime()
LE_FULL_API le_result_t le_clk_ConvertToTime | ( | const char * | formatSpecStrPtr, |
const char * | srcStrPtr, | ||
le_clk_Time_t * | timePtr | ||
) |
Generate an absolute date/time value as UTC time representation of a given printable string representation (no timezone offset applied).
- Returns
- LE_OK if the conversion was successful
- LE_BAD_PARAMETER if an invalid parameter is provided
- LE_FAULT if an error occurred
- Parameters
-
[in] formatSpecStrPtr Format specifier string, using conversion specifiers defined for strptime(). [in] srcStrPtr Formatted date/time string. [out] timePtr Converted date/time.
◆ le_clk_ConvertToUTCString()
le_result_t le_clk_ConvertToUTCString | ( | le_clk_Time_t | time, |
const char * | formatSpecStrPtr, | ||
char * | destStrPtr, | ||
size_t | destSize, | ||
size_t * | numBytesPtr | ||
) |
Generate a printable string representation of a given absolute date/time value as UTC time (no timezone offset applied).
The formatted date/time string, including NULL-terminator, will be copied to the destination buffer, provided it fits, and the number of bytes copied (not including the NULL-terminator) will be returned in numBytesPtr.
If the formatted date/time string does not fit in the destination buffer, the contents of the destination buffer will be undefined and the value returned in numBytesPtr will be zero.
- Returns
- LE_OK if the formatted string was copied to destStrPtr
- LE_OVERFLOW if the formatted string would not fit in destStrPtr
- Parameters
-
[in] time date/time to convert [in] formatSpecStrPtr Format specifier string, using conversion specifiers defined for strftime(). [out] destStrPtr Destination for the formatted date/time string [in] destSize Size of the destination buffer in bytes. [out] numBytesPtr Number of bytes copied, not including NULL-terminator. Parameter can be set to NULL if the number of bytes copied is not needed.
◆ le_clk_Equal()
bool le_clk_Equal | ( | le_clk_Time_t | timeA, |
le_clk_Time_t | timeB | ||
) |
Compare two time values.
- Returns
- TRUE if TimeA == TimeB
- FALSE otherwise
◆ le_clk_GetAbsoluteTime()
le_clk_Time_t le_clk_GetAbsoluteTime | ( | void | ) |
Get absolute time since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
- Returns
- Absolute time in seconds/microseconds
- Note
- Absolute time includes any time that the processor is suspended.
◆ le_clk_GetLocalDateTimeString()
le_result_t le_clk_GetLocalDateTimeString | ( | const char * | formatSpecStrPtr, |
char * | destStrPtr, | ||
size_t | destSize, | ||
size_t * | numBytesPtr | ||
) |
Get the Local date/time as a formatted string.
The formatted date/time string, including NULL-terminator, will be copied to the destination buffer, provided it fits, and the number of bytes copied (not including the NULL-terminator) will be returned in numBytesPtr.
If the formatted date/time string does not fit in the destination buffer, then the contents of the destination buffer will be undefined, and the value returned in numBytesPtr will be zero.
- Returns
- LE_OK if the formatted string was copied to destStrPtr.
- LE_OVERFLOW if the formatted string would not fit in destStrPtr.
- Parameters
-
[in] formatSpecStrPtr Format specifier string, using conversion specifiers defined for strftime(). [out] destStrPtr Destination for the formatted date/time string [in] destSize Size of the destination buffer in bytes. [out] numBytesPtr Number of bytes copied, not including NULL-terminator. Parameter can be set to NULL if the number of bytes copied is not needed.
◆ le_clk_GetRelativeTime()
le_clk_Time_t le_clk_GetRelativeTime | ( | void | ) |
Get relative time since a fixed but unspecified starting point.
- Returns
- Relative time in seconds/microseconds
- Note
- Relative time includes any time that the processor is suspended.
◆ le_clk_GetUTCDateTimeString()
le_result_t le_clk_GetUTCDateTimeString | ( | const char * | formatSpecStrPtr, |
char * | destStrPtr, | ||
size_t | destSize, | ||
size_t * | numBytesPtr | ||
) |
Get the UTC date/time as a formatted string.
The formatted date/time string, including NULL-terminator, will be copied to the destination buffer, provided it fits, and the number of bytes copied (not including the NULL-terminator) will be returned in numBytesPtr.
If the formatted date/time string does not fit in the destination buffer, the contents of the destination buffer will be undefined and the value returned in numBytesPtr will be zero.
- Returns
- LE_OK if the formatted string was copied to destStrPtr
- LE_OVERFLOW if the formatted string would not fit in destStrPtr
- Parameters
-
[in] formatSpecStrPtr Format specifier string, using conversion specifiers defined for strftime(). [out] destStrPtr Destination for the formatted date/time string [in] destSize Size of the destination buffer in bytes. [out] numBytesPtr Number of bytes copied, not including NULL-terminator. Parameter can be set to NULL if the number of bytes copied is not needed.
◆ le_clk_GreaterThan()
bool le_clk_GreaterThan | ( | le_clk_Time_t | timeA, |
le_clk_Time_t | timeB | ||
) |
Compare two time values.
- Returns
- TRUE if TimeA > TimeB
- FALSE otherwise
◆ le_clk_Multiply()
le_clk_Time_t le_clk_Multiply | ( | le_clk_Time_t | timeA, |
int | scaleFactor | ||
) |
Multiply the time by a scale factor, and return the result
- Returns
- Time multiplied by scale factor
◆ le_clk_SetAbsoluteTime()
le_result_t le_clk_SetAbsoluteTime | ( | le_clk_Time_t | absoluteTime | ) |
Set absolute time since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
- Note
- Only unsandboxed application can set the date/time.
- Returns
- LE_OK if the function succeeded
- LE_BAD_PARAMETER if an invalid parameter is provided
- LE_NOT_PERMITTED if the operation is not permitted
- LE_FAULT if an error occurred
- Parameters
-
[in] absoluteTime Absolute time in seconds/microseconds
◆ le_clk_SetTimezoneFile()
le_result_t le_clk_SetTimezoneFile | ( | const int32_t | timezoneOffsetSeconds, |
const uint8_t | dstOffsetHours | ||
) |
Set the timezone information
- Returns
- LE_OK if the time is correctly set
- LE_FAULT if an error occurred
- LE_UNSUPPORTED if the function is not supported
- Parameters
-
[in] timezoneOffsetSeconds Timezone offset in seconds [in] dstOffsetHours Daylight savings adjustment in hours
◆ le_clk_SetUTCDateTimeString()
LE_FULL_API le_result_t le_clk_SetUTCDateTimeString | ( | const char * | formatSpecStrPtr, |
const char * | srcStrPtr | ||
) |
Set the UTC date/time as a formatted string.
- Note
- Only unsandboxed application can set the date/time.
- Returns
- LE_OK if the time is correctly set
- LE_BAD_PARAMETER if an invalid parameter is provided
- LE_NOT_PERMITTED if the operation is not permitted
- LE_FAULT if an error occurred
- Parameters
-
[in] formatSpecStrPtr Format specifier string, using conversion specifiers defined for strptime(). [in] srcStrPtr Formatted date/time string.
◆ le_clk_Sub()
le_clk_Time_t le_clk_Sub | ( | le_clk_Time_t | timeA, |
le_clk_Time_t | timeB | ||
) |
Subtract two time values, and return the result.
- Returns
- Result of (timeA - timeB)