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.
TimeZone.cpp
1 #include <Print.h>
2 #include "common/util.h"
3 #include "TimeZone.h"
4 
5 namespace ace_time {
6 
7 void TimeZone::printTo(Print& printer) const {
8  printer.print('[');
9  if (mType == kTypeFixed) {
10  if (mOffset.isZero()) {
11  printer.print("UTC");
12  } else{
13  mOffset.printTo(printer);
14  }
15  } else {
16  mZoneSpecifier->printTo(printer);
17  }
18  printer.print(']');
19 }
20 
21 void TimeZone::printAbbrevTo(Print& printer, acetime_t epochSeconds) const {
22  if (mType == kTypeFixed) {
23  if (mOffset.isZero()) {
24  printer.print("UTC");
25  } else{
26  mOffset.printTo(printer);
27  }
28  } else {
29  printer.print(mZoneSpecifier->getAbbrev(epochSeconds));
30  }
31 }
32 
33 }
virtual void printTo(Print &printer) const =0
Print a human-readable identifier.
const ZoneSpecifier * mZoneSpecifier
Used if mType == mTypeZoneSpecifier.
Definition: TimeZone.h:181
void printAbbrevTo(Print &printer, acetime_t epochSeconds) const
Print the time zone abbreviation for the given epochSeconds.
Definition: TimeZone.cpp:21
void printTo(Print &printer) const
Print the human readable representation of the time zone.
Definition: TimeZone.cpp:7
TimeOffset mOffset
Used if mType == mTypeFixed.
Definition: TimeZone.h:178
void printTo(Print &printer) const
Print the human readable string.
Definition: TimeOffset.cpp:10
bool isZero() const
Returns true if offset is 00:00.
Definition: TimeOffset.h:109
virtual const char * getAbbrev(acetime_t epochSeconds) const =0
Return the time zone abbreviation at epochSeconds.