Skip to content

Commit 352722a

Browse files
authored
Merge pull request #15 from bxparks/develop
0.7.1 - replace TimeZone::printToAbbrev() with getAbbrev()
2 parents 7c2b39b + a6166bc commit 352722a

File tree

20 files changed

+111
-94
lines changed

20 files changed

+111
-94
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

33
* Unreleased
4+
* 0.7.1
5+
* Replace `TimeZone::printAbbrevTo()` with more
6+
flexible and useful `TimeZone::getAbbrev()`.
47
* 0.7
58
* Change TimeZoneData to store mStdOffset and mDstOffset in units of
69
one minute (instead of 15-minute increments, "code") in the off chance

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Conversion from an epochSeconds to date-time components including timezone
204204
* 2.8 microseconds on an ESP32,
205205
* 6 microseconds on a Teensy 3.2.
206206

207-
**Version**: 0.7 (2019-08-13, TZ DB version 2019b, beta)
207+
**Version**: 0.7.1 (2019-08-13, TZ DB version 2019b, beta)
208208

209209
**Status**: Upgraded to latest TZ DB version 2019b. Validated against 3
210210
other timezone libraries (Python, Java, C++). See [CHANGELOG.md](CHANGELOG.md)
@@ -273,7 +273,7 @@ void setup() {
273273

274274
// Print the current time zone abbreviation, e.g. "PST" or "PDT"
275275
Serial.print(F("Abbreviation: "));
276-
pacificTz.printAbbrevTo(Serial, epochSeconds);
276+
Serial.print(pacificTz.getAbbrev(epochSeconds));
277277
Serial.println();
278278

279279
// Create from epoch seconds. London is still on standard time.
@@ -291,7 +291,7 @@ void setup() {
291291

292292
// Print the current time zone abbreviation, e.g. "PST" or "PDT"
293293
Serial.print(F("Abbreviation: "));
294-
londonTz.printAbbrevTo(Serial, epochSeconds);
294+
Serial.print(londonTz.getAbbrev(epochSeconds));
295295
Serial.println();
296296

297297
Serial.println(F("=== Compare ZonedDateTime"));

USER_GUIDE.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
See the [README.md](README.md) for introductory background.
44

5-
Version: 0.7 (2019-08-13, TZ DB version 2019b, beta)
5+
Version: 0.7.1 (2019-08-13, TZ DB version 2019b, beta)
66

77
## Installation
88

@@ -798,6 +798,7 @@ class TimeZone {
798798

799799
TimeOffset getUtcOffset(acetime_t epochSeconds) const;
800800
TimeOffset getDeltaOffset(acetime_t epochSeconds) const;
801+
const char* getAbbrev(acetime_t epochSeconds) const;
801802
TimeOffset getUtcOffsetForDateTime(const LocalDateTime& ldt) const;
802803

803804
bool isUtc() const;
@@ -806,7 +807,6 @@ class TimeZone {
806807

807808
void printTo(Print& printer) const;
808809
void printShortTo(Print& printer) const;
809-
void printAbbrevTo(Print& printer, acetime_t epochSeconds) const;
810810
};
811811

812812
}
@@ -817,6 +817,15 @@ DST offset) at the given `epochSeconds`. The `getDeltaOffset()` returns only the
817817
additional DST offset; if DST is not in effect at the given `epochSeconds`, this
818818
returns a `TimeOffset` whose `isZero()` returns true.
819819
820+
The `getAbbrev(epochSeconds)` method returns the human-readable timezone
821+
abbreviation used at the given `epochSeconds`. For example, this be "PST" for
822+
Pacific Standard Time, or "BST" for British Summer Time. The returned c-string
823+
should be used as soon as possible (e.g. printed to Serial) because the pointer
824+
points to a temporary buffer whose contents may change upon subsequent calls to
825+
`getUtcOffset()`, `getDeltaOffset()` and `getAbbrev()`. If the abbreviation
826+
needs to be saved for a longer period of time, it should be saved to another
827+
char buffer.
828+
820829
The `getUtcOffsetForDateTime(localDateTime)` method returns the best guess of
821830
the total UTC offset at the given local date time. This method is not
822831
normally expected to be used by the app developer directly. The reaon that this
@@ -845,11 +854,6 @@ last component of the IANA TZ Database zone names. In other words,
845854
`"America/Los_Angeles"` is printed as `"Los_Angeles"`. This is helpful for
846855
printing on small width OLED displays.
847856
848-
The `printAbbrevTo(printer, epochSeconds)` method prints the human-readable
849-
timezone abbreviation used at the given `epochSeconds` to the `printer`. For
850-
example, this be "PST" for Pacific Standard Time, or "BST" for British Summer
851-
Time.
852-
853857
#### Manual TimeZone (kTypeManual)
854858
855859
The default constructor creates a `TimeZone` in UTC time zone with no
@@ -2585,9 +2589,10 @@ and
25852589
[ExtendedValidationUsingHinnantDateTest](tests/validation/ExtendedValidationUsingHinnantDateTest/)
25862590
validation tests (in v0.7) which are the AceTime algorithms to the Hinnant Date
25872591
algorithms. For all times zones between the years 2000 until 2050, the AceTime
2588-
UTC offsets (`TimeZone::getUtcOffset()`) and epochSecond conversion to
2589-
date components (`ZonedDateTime::fromEpochSeconds()`) match the results from the
2590-
Hinannt Date libraries perfectly.
2592+
UTC offsets (`TimeZone::getUtcOffset()`), timezone abbreviations
2593+
(`TimeZone::getAbbrev()`), and epochSecond conversion to date components
2594+
(`ZonedDateTime::fromEpochSeconds()`) match the results from the Hinannt Date
2595+
libraries.
25912596
25922597
### Google cctz
25932598

examples/HelloDateTime/HelloDateTime.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void setup() {
7676

7777
// Print the current time zone abbreviation, e.g. "PST" or "PDT"
7878
SERIAL_PORT_MONITOR.print(F("Abbreviation: "));
79-
pacificTz.printAbbrevTo(SERIAL_PORT_MONITOR, epochSeconds);
79+
SERIAL_PORT_MONITOR.print(pacificTz.getAbbrev(epochSeconds));
8080
SERIAL_PORT_MONITOR.println();
8181

8282
// Create from epoch seconds. London is still on standard time.
@@ -94,7 +94,7 @@ void setup() {
9494

9595
// Print the current time zone abbreviation, e.g. "PST" or "PDT"
9696
SERIAL_PORT_MONITOR.print(F("Abbreviation: "));
97-
londonTz.printAbbrevTo(SERIAL_PORT_MONITOR, epochSeconds);
97+
SERIAL_PORT_MONITOR.print(londonTz.getAbbrev(epochSeconds));
9898
SERIAL_PORT_MONITOR.println();
9999

100100
SERIAL_PORT_MONITOR.println(F("=== Compare ZonedDateTime"));

examples/WorldClock/Presenter.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
void Presenter::displayAbout() const {
66
mOled.set1X();
77

8-
// For smallest flash memory size, use F() macros for these longer
9-
// strings, but no F() for shorter version strings.
10-
mOled.print(F("AT: "));
8+
// For smallest flash memory size, use F() macros for these longer strings,
9+
// but no F() for shorter version strings. Comment out the headers, to save
10+
// 38 bytes because I'm 12 bytes over the 30kB limit of a Pro Micro.
11+
12+
//mOled.print(F("AT: "));
1113
mOled.println(F(ACE_TIME_VERSION_STRING));
12-
mOled.print(F("TZ: "));
14+
//mOled.print(F("TZ: "));
1315
mOled.println(zonedb::kTzDatabaseVersion);
1416
}

examples/WorldClock/Presenter.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ class Presenter {
9999
const ZonedDateTime dateTime = ZonedDateTime::forEpochSeconds(
100100
mRenderingInfo.now, mRenderingInfo.timeZone);
101101
if (dateTime.isError()) {
102-
mOled.println(F("9999-99-99"));
103-
mOled.println(F("99:99:99"));
104-
mOled.println(F("Error"));
102+
clearDisplay();
103+
mOled.println(F("<Error>"));
105104
return;
106105
}
107106

@@ -145,7 +144,7 @@ class Presenter {
145144
// place name
146145
mOled.println();
147146
acetime_t epochSeconds = dateTime.toEpochSeconds();
148-
dateTime.timeZone().printAbbrevTo(mOled, epochSeconds);
147+
mOled.print(dateTime.timeZone().getAbbrev(epochSeconds));
149148
mOled.print(' ');
150149
mOled.print('(');
151150
mOled.print(mRenderingInfo.name);
@@ -222,7 +221,7 @@ class Presenter {
222221

223222
// abbreviation and place name
224223
mOled.println();
225-
dateTime.timeZone().printAbbrevTo(mOled, mRenderingInfo.now);
224+
mOled.print(dateTime.timeZone().getAbbrev(mRenderingInfo.now));
226225
mOled.print(' ');
227226
mOled.print('(');
228227
mOled.print(mRenderingInfo.name);

examples/WorldClock/RenderingInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct RenderingInfo {
2020
const char* name;
2121
uint8_t hourMode;
2222
bool blinkingColon;
23-
ace_time::TimeZone timeZone;
23+
TimeZone timeZone;
2424
};
2525

2626
#endif

keywords.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ toTimeZoneData KEYWORD2
212212
getType KEYWORD2
213213
getUtcOffset KEYWORD2
214214
getDeltaOffset KEYWORD2
215+
getAbbrev KEYWORD2
215216
getOffsetDateTime KEYWORD2
216217
isUtc KEYWORD2
217218
isDst KEYWORD2
218219
setDstOffset KEYWORD2
219220
printTo KEYWORD2
220221
printShortTo KEYWORD2
221-
printAbbrevTo KEYWORD2
222222

223223
# ZoneManager.h
224224
createForZoneInfo KEYWORD2

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AceTime
2-
version=0.7
2+
version=0.7.1
33
author=Brian T. Park <[email protected]>
44
maintainer=Brian T. Park <[email protected]>
55
sentence=Date, time, clock, and TZ Database timezones for Arduino.

src/AceTime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#include "ace_time/clock/SystemClockCoroutine.h"
5656

5757
// Version format: xxyyzz == "xx.yy.zz"
58-
#define ACE_TIME_VERSION 700
59-
#define ACE_TIME_VERSION_STRING "0.7"
58+
#define ACE_TIME_VERSION 701
59+
#define ACE_TIME_VERSION_STRING "0.7.1"
6060

6161
#endif

0 commit comments

Comments
 (0)