Unix / Epoch time
Unix time (also known as POSIX time or Epoch time) is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds. It is used widely in Unix-like and many other operating systems and file formats.
Example: 1419086327 (2014-12-20T14:38:47Z)
Waspmote API defines some functions to use this time format which can be useful in order to translate dates into seconds and perform addition or subtraction of time.
An example of the functions that are shown below: https://development.libelium.com/rtc-08-unixepoch-time/
Getting Epoch time
The function getEpochTime()
permits to calculate the Unix time associated to a specific year, month, day, hour, minute and second values. It is possible to indicate these values as input or use the current values of the RTC.
Example of use:
The function getEpochTime()
updates the RTC attributes because it calls getTime()
function.
Breaking Epoch time into 'Time and Date'
The function breakTimeAbsolute()
permits to convert the input epoch time to time and date values (as UTC components). Thus, it can be useful to add/subtract times. For example: get Epoch time from RTC and add several seconds to calculate a new time instant.
The structure called timestamp_t
is defined in WaspRTC class for converting epoch time into UTC timestamps.
Example of use:
The function breakTimeOffset()
permits to convert the input (great period of seconds) into offset time values (as the number of days, hours, minutes and seconds that the input argument defines). Thus, it can be useful to add/subtract times. For example: get Epoch time from RTC in different instants and then calculate the difference as number of days, hours, minutes and seconds.
The structure called timestamp_t
is defined in WaspRTC class for converting great periods of seconds into number of days, hours, minutes and seconds.
Example of use:
Last updated