Digi XBee(R) ANSI C Host Library
Files | Macros | Typedefs | Functions | Variables
Portable time functions

Portable time functions using January 1, 2000 as the epoch. More...

Files

file  time.h
 
file  xbee_time.c
 

Macros

#define XBEE_UTCTIME_INVALID   0xFFFFFFFF
 
#define _xbee_time_debug
 

Typedefs

typedef uint32_t xbee_utctime_t
 

Functions

struct tm * xbee_gmtime (struct tm *dest_tm, xbee_utctime_t timestamp)
 Converts a UTCTime value into a "broken-down time" (a struct tm) for directly accessing month, day, year, hour, minute and second, or for use with other functions from <time.h>. More...
 
xbee_utctime_t xbee_mktime (struct tm *time_rec)
 Convert a struct tm (from the Standard C Library's time.h) to a xbee_utctime_t type (number of seconds since Midnight January 1, 2000 UTC). More...
 
void _xbee_mktime_normalize (int *major, int *minor, int count)
 

Variables

const uint16_t _xbee_time_jom [2][12]
 
const uint8_t _xbee_time_dom [2][12]
 

Detailed Description

Portable time functions using January 1, 2000 as the epoch.

Implementations of time.h functions from the Standard C Library for platforms that may not support them, or for writing portable code to use January 1, 2000 as the epoch (as in the ZigBee specification).

Function Documentation

void _xbee_mktime_normalize ( int *  major,
int *  minor,
int  count 
)

Normalize minor such that it is in the range [0, count) by adding count to minor (and subtracting 1 from major) or subtracting count from minor (and adding 1 to major).

Referenced by xbee_mktime().

struct tm * xbee_gmtime ( struct tm *  dest_tm,
xbee_utctime_t  timestamp 
)

Converts a UTCTime value into a "broken-down time" (a struct tm) for directly accessing month, day, year, hour, minute and second, or for use with other functions from <time.h>.

Parameters
[out]dest_tmDestination "struct tm" structure to hold the broken-down time. See time.h for details on that structure.
[in]timestampTimestamp to convert. Number of seconds since 1/1/2000 UTC.
Returns
Returns the dest_tm parameter.

Referenced by _zcl_format_utctime().

xbee_utctime_t xbee_mktime ( struct tm *  time_rec)

Convert a struct tm (from the Standard C Library's time.h) to a xbee_utctime_t type (number of seconds since Midnight January 1, 2000 UTC).

Does NOT properly handle DST and Timezones in the struct tm. Assumes the struct is in UTC. Keep this in mind if passing a struct tm generated by the host's gmtime() to this function.

Parameters
[in]time_recbroken-down (componentized) calendar representation of time
Returns
number of seconds since 01/01/2000 00:00:00 UTC or XBEE_UTCTIME_INVALID if time_rec is before 1/1/2000
Todo:
Handle DST and time zones.

References _xbee_mktime_normalize().

Variable Documentation

const uint8_t _xbee_time_dom
Initial value:
=
{
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
}
const uint16_t _xbee_time_jom
Initial value:
=
{
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334},
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}
}