Class to support local/UTC time conversions using rules. More...
#include <Timezone.h>
Public Member Functions | |
Timezone () | |
Timezone (const TimeChangeRule &dstStart, const TimeChangeRule &stdStart) | |
void | init (const TimeChangeRule &dstStart, const TimeChangeRule &stdStart) |
time_t | toLocal (time_t utc, const TimeChangeRule **p_tcr=nullptr) |
Convert the given UTC time to local time, standard or daylight time. More... | |
time_t | toUTC (time_t local) |
Convert the given local time to UTC time. More... | |
bool | utcIsDST (time_t utc) |
Determine whether the UTC time is within the DST interval or the Standard time interval. More... | |
bool | locIsDST (time_t local) |
Determine whether the given local time is within the DST interval or the Standard time interval. More... | |
const char * | timeTag (bool isDst) const |
Return the appropriate dalight-savings tag to append to displayed times. More... | |
const char * | utcTimeTag (time_t utc) |
Return the appropriate time tag for a UTC time. More... | |
const char * | localTimeTag (time_t local) |
Return the appropriate time tag for a local time. More... | |
Detailed Description
Class to support local/UTC time conversions using rules.
Constructor & Destructor Documentation
◆ Timezone() [1/2]
|
inline |
◆ Timezone() [2/2]
|
inline |
Member Function Documentation
◆ init()
void Timezone::init | ( | const TimeChangeRule & | dstStart, |
const TimeChangeRule & | stdStart | ||
) |
◆ localTimeTag()
|
inline |
Return the appropriate time tag for a local time.
- Parameters
-
local The local time
- Return values
-
const char* Tag, such as UTC, BST, etc.
◆ locIsDST()
bool Timezone::locIsDST | ( | time_t | local | ) |
Determine whether the given local time is within the DST interval or the Standard time interval.
- Parameters
-
local Local time
- Return values
-
bool true if time is within DST
◆ timeTag()
|
inline |
Return the appropriate dalight-savings tag to append to displayed times.
- Parameters
-
isDst true if DST tag is required, otherwise non-DST tag is returned
- Return values
-
const char* The tag
◆ toLocal()
time_t Timezone::toLocal | ( | time_t | utc, |
const TimeChangeRule ** | p_tcr = nullptr |
||
) |
Convert the given UTC time to local time, standard or daylight time.
- Parameters
-
utc Time in UTC p_tcr Optionally return the rule used to convert the time
- Return values
-
time_t The local time
◆ toUTC()
time_t Timezone::toUTC | ( | time_t | local | ) |
Convert the given local time to UTC time.
- Parameters
-
local Local time
- Return values
-
time_t Time in UTC
- Note
WARNING: This function is provided for completeness, but should seldom be needed and should be used sparingly and carefully.
Ambiguous situations occur after the Standard-to-DST and the DST-to-Standard time transitions. When changing to DST, there is one hour of local time that does not exist, since the clock moves forward one hour. Similarly, when changing to standard time, there is one hour of local times that occur twice since the clock moves back one hour.
This function does not test whether it is passed an erroneous time value during the Local -> DST transition that does not exist. If passed such a time, an incorrect UTC time value will be returned.
If passed a local time value during the DST -> Local transition that occurs twice, it will be treated as the earlier time, i.e. the time that occurs before the transition.
Calling this function with local times during a transition interval should be avoided.
◆ utcIsDST()
bool Timezone::utcIsDST | ( | time_t | utc | ) |
Determine whether the UTC time is within the DST interval or the Standard time interval.
- Parameters
-
utc
- Return values
-
bool true if time is within DST
◆ utcTimeTag()
|
inline |
Return the appropriate time tag for a UTC time.
- Parameters
-
utc The time in UTC
- Return values
-
const char* Tag, such as UTC, BST, etc.
The documentation for this class was generated from the following file: