All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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)
 
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)
 

Detailed Description

Legato Real-time Clock API include file.

Copyright (C) Sierra Wireless, Inc. 2014. All rights reserved. Use of this work is subject to license.

Function Documentation

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_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]timedate/time to convert
[in]formatSpecStrPtrFormat specifier string, using conversion specifiers defined for strftime().
[out]destStrPtrDestination for the formatted date/time string
[in]destSizeSize of the destination buffer in bytes.
[out]numBytesPtrNumber of bytes copied, not including NULL-terminator. Parameter can be set to NULL if the number of bytes copied is not needed.
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]timedate/time to convert
[in]formatSpecStrPtrFormat specifier string, using conversion specifiers defined for strftime().
[out]destStrPtrDestination for the formatted date/time string
[in]destSizeSize of the destination buffer in bytes.
[out]numBytesPtrNumber of bytes copied, not including NULL-terminator. Parameter can be set to NULL if the number of bytes copied is not needed.
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_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]formatSpecStrPtrFormat specifier string, using conversion specifiers defined for strftime().
[out]destStrPtrDestination for the formatted date/time string
[in]destSizeSize of the destination buffer in bytes.
[out]numBytesPtrNumber of bytes copied, not including NULL-terminator. Parameter can be set to NULL if the number of bytes copied is not needed.
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_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]formatSpecStrPtrFormat specifier string, using conversion specifiers defined for strftime().
[out]destStrPtrDestination for the formatted date/time string
[in]destSizeSize of the destination buffer in bytes.
[out]numBytesPtrNumber of bytes copied, not including NULL-terminator. Parameter can be set to NULL if the number of bytes copied is not needed.
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_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_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)