AceTime  1.7.5
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
BasicZone.cpp
1 /*
2  * MIT License
3  * Copyright (c) 2019 Brian T. Park
4  */
5 
6 #include <Arduino.h>
7 #include <AceCommon.h> // KString
8 #include "internal/BrokerCommon.h" // findShortName()
9 #include "BasicZone.h"
10 
11 using ace_common::KString;
12 using ace_common::printReplaceCharTo;
13 using ace_time::internal::findShortName;
15 
16 namespace ace_time {
17 
18 #if ACE_TIME_USE_PROGMEM
19 
20 void BasicZone::printNameTo(Print& printer) const {
21  const __FlashStringHelper* name = mZoneInfoBroker.name();
22  const ZoneContext* zoneContext = mZoneInfoBroker.zoneContext();
23  KString kname(name, zoneContext->fragments, zoneContext->numFragments);
24  kname.printTo(printer);
25 }
26 
27 void BasicZone::printShortNameTo(Print& printer) const {
28  const __FlashStringHelper* name = mZoneInfoBroker.name();
29  const __FlashStringHelper* shortName = findShortName(name);
30  printReplaceCharTo(printer, shortName, '_', ' ');
31 }
32 
33 #else
34 
35 void BasicZone::printNameTo(Print& printer) const {
36  const char* name = mZoneInfoBroker.name();
37  const ZoneContext* zoneContext = mZoneInfoBroker.zoneContext();
38  KString kname(name, zoneContext->fragments, zoneContext->numFragments);
39  kname.printTo(printer);
40 }
41 
42 void BasicZone::printShortNameTo(Print& printer) const {
43  const char* name = mZoneInfoBroker.name();
44  const char* shortName = findShortName(name);
45  printReplaceCharTo(printer, shortName, '_', ' ');
46 }
47 
48 #endif // ACE_TIME_USE_PROGMEM
49 
50 } // ace_time
BrokerCommon.h
ace_time::BasicZone::printNameTo
void printNameTo(Print &printer) const
Print the full zone name to printer.
Definition: BasicZone.cpp:20
ace_time::internal::ZoneContext
Metadata about the zone database.
Definition: ZoneContext.h:16
ace_time::BasicZone::printShortNameTo
void printShortNameTo(Print &printer) const
Print the short pretty zone name to the printer.
Definition: BasicZone.cpp:27
ace_time::internal::ZoneContext::fragments
const char *const * fragments
Zone Name fragment list.
Definition: ZoneContext.h:47
ace_time::internal::ZoneContext::numFragments
uint8_t numFragments
Number of fragments.
Definition: ZoneContext.h:44