AceTime  0.1
Date and time classes for Arduino that supports the TZ DAtabase, and a system clock synchronized from an NTP server or an RTC chip.
Public Member Functions | List of all members
ace_time::ManualZoneSpecifier Class Reference

An implementation of ZoneSpecifier which allows the user to manually adjust the UTC offset and the DST flag. More...

#include <ManualZoneSpecifier.h>

Inheritance diagram for ace_time::ManualZoneSpecifier:
Inheritance graph
[legend]
Collaboration diagram for ace_time::ManualZoneSpecifier:
Collaboration graph
[legend]

Public Member Functions

 ManualZoneSpecifier (TimeOffset stdOffset=TimeOffset(), bool isDst=false, const char *stdAbbrev="", const char *dstAbbrev="", TimeOffset deltaOffset=TimeOffset::forHour(1))
 Constructor for a time zone with an offset from UTC that does not change with epochSeconds. More...
 
 ManualZoneSpecifier (const ManualZoneSpecifier &)=default
 Default copy constructor. More...
 
ManualZoneSpecifieroperator= (const ManualZoneSpecifier &)=default
 Default assignment operator. More...
 
TimeOffset stdOffset () const
 Get the standard UTC offset. More...
 
bool isDst () const
 Get the current isDst flag. More...
 
const char * stdAbbrev () const
 Get the standard abbreviation. More...
 
const char * dstAbbrev () const
 Get the DST abbreviation. More...
 
TimeOffset deltaOffset () const
 Get the DST delta offset. More...
 
void stdOffset (TimeOffset offset)
 Set the standard UTC offset. More...
 
void isDst (bool isDst)
 Set the current isDst flag. More...
 
TimeOffset getUtcOffset (acetime_t) const override
 Return the total UTC offset at epochSeconds, including DST offset. More...
 
TimeOffset getDeltaOffset (acetime_t) const override
 Return the DST delta offset at epochSeconds. More...
 
const char * getAbbrev (acetime_t) const override
 Return the time zone abbreviation at epochSeconds. More...
 
TimeOffset getUtcOffsetForDateTime (const LocalDateTime &) const override
 Return the UTC offset matching the given the date/time components. More...
 
void printTo (Print &printer) const override
 Print a human-readable identifier. More...
 
- Public Member Functions inherited from ace_time::ZoneSpecifier
uint8_t getType () const
 Return the kTypeXxx of the current instance. More...
 

Additional Inherited Members

- Static Public Attributes inherited from ace_time::ZoneSpecifier
static const uint8_t kTypeManual = 1
 Indicate ManualZoneSpecifier. More...
 
static const uint8_t kTypeBasic = 2
 Indicate BasicZoneSpecifier. More...
 
static const uint8_t kTypeExtended = 3
 Indicate ExtendedZoneSpecifier. More...
 
- Protected Member Functions inherited from ace_time::ZoneSpecifier
 ZoneSpecifier (const ZoneSpecifier &)=default
 
ZoneSpecifieroperator= (const ZoneSpecifier &)=default
 
 ZoneSpecifier (uint8_t type)
 Constructor. More...
 
- Protected Attributes inherited from ace_time::ZoneSpecifier
uint8_t mType
 

Detailed Description

An implementation of ZoneSpecifier which allows the user to manually adjust the UTC offset and the DST flag.

Unlike BasicZoneSpecifier and ExtendedZoneSpecifier, this class is mutable and copyable to allow the application to detect changes to the timeOffset made by the user.

Definition at line 16 of file ManualZoneSpecifier.h.

Constructor & Destructor Documentation

ace_time::ManualZoneSpecifier::ManualZoneSpecifier ( TimeOffset  stdOffset = TimeOffset(),
bool  isDst = false,
const char *  stdAbbrev = "",
const char *  dstAbbrev = "",
TimeOffset  deltaOffset = TimeOffset::forHour(1) 
)
inlineexplicit

Constructor for a time zone with an offset from UTC that does not change with epochSeconds.

The internall isDst flag is set to 'false' initially, and can be changed using the isDst(bool) mutator.

Of the 5 parameters in the constructor, only stdOffset and isDst are mutable after construction. The mutators are expected to be called from applications that allow the user to change the UTC offset and isDst flags during runtime. The others are not exposed to be mutable because it seems unrealistic to expect the user to know the standard and DST timezone abbreviations.

Parameters
stdOffsetbase offset of the zone, can be changed using the stdOffset(TimeOffset) mutator (default: 00:00)
isDsttrue if DST shfit is active (default: false)
stdAbbrevtime zone abbreviation during normal time. Cannot be nullptr. Cannot be changed after construction. (default: "")
dstAbbrevtime zone abbreviation during DST time. Cannot be nullptr. Cannot be changed after construction. (default: "").
deltaOffsetadditional UTC offset during DST time. Cannot be changed after construction. (default: +01:00).

Definition at line 41 of file ManualZoneSpecifier.h.

ace_time::ManualZoneSpecifier::ManualZoneSpecifier ( const ManualZoneSpecifier )
default

Default copy constructor.

Member Function Documentation

TimeOffset ace_time::ManualZoneSpecifier::deltaOffset ( ) const
inline

Get the DST delta offset.

Definition at line 73 of file ManualZoneSpecifier.h.

const char* ace_time::ManualZoneSpecifier::dstAbbrev ( ) const
inline

Get the DST abbreviation.

Definition at line 70 of file ManualZoneSpecifier.h.

const char* ace_time::ManualZoneSpecifier::getAbbrev ( acetime_t  epochSeconds) const
inlineoverridevirtual

Return the time zone abbreviation at epochSeconds.

This is an experimental method that has not been tested thoroughly. Use with caution.

Implements ace_time::ZoneSpecifier.

Definition at line 101 of file ManualZoneSpecifier.h.

TimeOffset ace_time::ManualZoneSpecifier::getDeltaOffset ( acetime_t  epochSeconds) const
inlineoverridevirtual

Return the DST delta offset at epochSeconds.

This is an experimental method that has not been tested thoroughly. Use with caution.

Implements ace_time::ZoneSpecifier.

Definition at line 97 of file ManualZoneSpecifier.h.

TimeOffset ace_time::ManualZoneSpecifier::getUtcOffset ( acetime_t  epochSeconds) const
inlineoverridevirtual

Return the total UTC offset at epochSeconds, including DST offset.

Implements ace_time::ZoneSpecifier.

Definition at line 87 of file ManualZoneSpecifier.h.

TimeOffset ace_time::ManualZoneSpecifier::getUtcOffsetForDateTime ( const LocalDateTime ldt) const
inlineoverridevirtual

Return the UTC offset matching the given the date/time components.

Implements ace_time::ZoneSpecifier.

Definition at line 105 of file ManualZoneSpecifier.h.

bool ace_time::ManualZoneSpecifier::isDst ( ) const
inline

Get the current isDst flag.

Definition at line 64 of file ManualZoneSpecifier.h.

void ace_time::ManualZoneSpecifier::isDst ( bool  isDst)
inline

Set the current isDst flag.

This is expected to be used by applications that allow the user to manually select the DST flag.

Definition at line 85 of file ManualZoneSpecifier.h.

ManualZoneSpecifier& ace_time::ManualZoneSpecifier::operator= ( const ManualZoneSpecifier )
default

Default assignment operator.

void ace_time::ManualZoneSpecifier::printTo ( Print &  printer) const
overridevirtual

Print a human-readable identifier.

Implements ace_time::ZoneSpecifier.

Definition at line 6 of file ManualZoneSpecifier.cpp.

const char* ace_time::ManualZoneSpecifier::stdAbbrev ( ) const
inline

Get the standard abbreviation.

Definition at line 67 of file ManualZoneSpecifier.h.

TimeOffset ace_time::ManualZoneSpecifier::stdOffset ( ) const
inline

Get the standard UTC offset.

Definition at line 61 of file ManualZoneSpecifier.h.

void ace_time::ManualZoneSpecifier::stdOffset ( TimeOffset  offset)
inline

Set the standard UTC offset.

This can be used by applications that allow the user to select a particular UTC offset.

Definition at line 79 of file ManualZoneSpecifier.h.


The documentation for this class was generated from the following files: