ThingWorx Edge C SDK > Porting to Another Platform > Date/Time Functions
Date/Time Functions
The SDK requires a timer with millisecond granularity for things such as messaging timeouts and task scheduling. In addition, some form of real-time clock may be required if using DATETIME base types or the standard logging plugin. The DATETIME base type uses the standard javascript representation of milliseconds since the epoch of midnight 1/1/1970. In the Linux environment this is represented as an unsigned 64-bit integer with a direct correlation to the number of milliseconds, but the SDK makes no requirement that a DATETIME must be a simple element.
/* Time */
typedef uint64_t DATETIME; /* AS DEFINED IN LINUX.H */
To support potentially complex DATETIME structures, a port of the SDK must provide a few DATETIME manipulation and comparison functions. The function definitions are in the file, twOSPort.h, but the implementations are typically in your OS-specific C file, or in the file, twLinux.c for a Linux port. The required functions are listed and described in the table that follows. For the signature and parameter definitions for the functions, refer to the Doxygen documentation provided with the SDK bundle.
Compare two DATETIME entities and returns a value of TRUE if t1 > t2 or FALSE if not.
Compare two DATETIME entities and returns a TRUE value if t1 < t2 or FALSE if not.
Add a number (msec) of milliseconds to the value in t1.
Get the current millisecond count since the system started (or since the epoch if the system time has millisecond granularity).
On systems where the real-time clock has a millisecond granularity, it is recommended that this value be the same as the current system time, representing the current date/time.
Get the current system time, representing milliseconds since the epoch. If utc is TRUE (the default for the SDK), the time is corrected to Universal Coordinate Time (UTC).
Get the current system time and converts it to a string using strftime formatting.
Convert a DATETIME to a string using strftime formatting.
Delay execution. In a single-threaded, single-processor system, this may be a blocking call.