Skip to content

Commit ac1ff2c

Browse files
authored
Merge pull request #108 from bxparks/develop
merge 2.1.0 into master
2 parents cdf3adf + 43514d8 commit ac1ff2c

File tree

103 files changed

+16461
-9121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+16461
-9121
lines changed

.github/workflows/aunit_tests.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
sudo apt update
2020
sudo apt install -y libcurl4-openssl-dev
2121
cd ..
22-
git clone https://github.com/HowardHinnant/date
23-
git clone https://github.com/bxparks/EpoxyDuino
24-
git clone https://github.com/bxparks/AceRoutine
25-
git clone https://github.com/bxparks/AUnit
26-
git clone https://github.com/bxparks/AceCommon
27-
git clone https://github.com/bxparks/AceWire
28-
git clone https://github.com/bxparks/AceSorting
22+
git clone --depth 1 https://github.com/HowardHinnant/date
23+
git clone --depth 1 https://github.com/bxparks/EpoxyDuino
24+
git clone --depth 1 https://github.com/bxparks/AceRoutine
25+
git clone --depth 1 https://github.com/bxparks/AUnit
26+
git clone --depth 1 https://github.com/bxparks/AceCommon
27+
git clone --depth 1 https://github.com/bxparks/AceWire
28+
git clone --depth 1 https://github.com/bxparks/AceSorting
2929
3030
- name: Verify examples
3131
run: |

.github/workflows/validation.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ jobs:
2626
- name: Checkout Additional Repos
2727
run: |
2828
cd ..
29-
git clone https://github.com/bxparks/EpoxyDuino
30-
git clone https://github.com/bxparks/AUnit
31-
git clone https://github.com/bxparks/AceCommon
32-
git clone https://github.com/bxparks/AceSorting
33-
git clone https://github.com/bxparks/AceTimeTools
34-
git clone https://github.com/bxparks/AceTimePython
35-
git clone https://github.com/bxparks/AceTimeValidation
29+
git clone --depth 1 https://github.com/bxparks/EpoxyDuino
30+
git clone --depth 1 https://github.com/bxparks/AUnit
31+
git clone --depth 1 https://github.com/bxparks/AceCommon
32+
git clone --depth 1 https://github.com/bxparks/AceSorting
33+
git clone --depth 1 https://github.com/bxparks/AceTimeTools
34+
git clone --depth 1 https://github.com/bxparks/AceTimePython
35+
git clone --depth 1 https://github.com/bxparks/AceTimeValidation
36+
git clone --depth 1 https://github.com/HowardHinnant/date
3637
git clone https://github.com/eggert/tz
37-
git clone https://github.com/HowardHinnant/date
3838
3939
- name: Set up Python 3.7
4040
uses: actions/setup-python@v2

CHANGELOG.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,52 @@
11
# Changelog
22

33
* Unreleased
4+
* 2.1.0 (2023-01-29, TZDB version 2022g)
5+
* There are a handful API breaking changes in this release in the pursuit of
6+
simpler and cleaner code. See the following for more info:
7+
* [Migrating to v2.1](MIGRATING.md#MigratingToVersion210)
8+
* [ZonedExtra](USER_GUIDE.md#ZonedExtra) in the User Guide
9+
* [Unified Links](USER_GUIDE.md#UnifiedLinks) in the User Guide
10+
* **Potentially Breaking**: zonedb,zonedbx
11+
* Rename `kPolicyXxx` to `kZonePolicyXxx` for consistency. These are
12+
expected to be used only internally, so shouldn't cause external
13+
breakage.
14+
* **Breaking**: `TimeZone.h`
15+
* Replace 3 separate extraction methods in `TimeZone` with a new
16+
`ZonedExtra` class
17+
* Removed: `TimeZone::getUtcOffset()`
18+
* Replaced by: `ZonedExtra::timeOffset()`
19+
* Removed: `TimeZone::getDeltaOffset()`
20+
* Replaced by: `ZonedExtra::dstOffset()`
21+
* Removed `TimeZone::getAbbrev()`
22+
* Replaced by: `ZonedExtra::abbrev()`
23+
* `ZonedExtra::abbrev()` returns pointer to a local string buffer
24+
instead of a transient buffer deep inside `Transition` object.
25+
* `TimeZone` becomes closer to being thread-safe
26+
* **New Class**: `ZonedExtra.h`
27+
* `ZonedExtra::forEpochSeconds(epochSeconds, tz)`
28+
* Create instance from epochSeconds and time zone.
29+
* `ZonedExtra::forLocalDateTime(ldt, tz)`
30+
* Create instance from LocalDateTime and time zone.
31+
* **Potentially Breaking**: Unified Links
32+
* Links are now first-class citizens, exactly the same as Zones.
33+
* Unify "fat links" and "symbolic links" into a single implementation.
34+
* Remove "thin links" to simplify the code.
35+
* `TimeZone` class simplified
36+
* Removed `followLink` flag on various methods.
37+
* Only 2 methods apply to Links: `isLink()` and
38+
`printTargetNameTo()`.
39+
* Simplify ZoneProcessors
40+
* `ZoneProcessor.h`, `ExtendedZoneProcessor.h`, `BasicZoneProcessor.h`
41+
* Remove: `getUtcOffset()`, `getDeltaOffset()`, `getAbbrev()`
42+
* Replaced by: `findByLocalDateTime()`, `findByEpochSeconds()`
43+
* These are internal helper methods not intended for public consumption.
44+
* Unit tests
45+
* Migrate most unit tests to use the smaller, testing zone databases at
46+
`testing/tzonedb/` and `testing/tzonedbx/`.
47+
* Reduces maintenance cost of various hand-crafted ZoneInfo and
48+
ZonePolicy entries for unit tests.
49+
* Can test against real timezones with predictable behavior.
450
* 2.0.1 (2022-12-04, TZDB 2022g)
551
* Prevent `ExtendedZoneProcssor::generateStartUntilTimes()` from
652
dereferencing uninitialized memory if there are no matching transitions.
@@ -38,7 +84,7 @@
3884
* Extend `untilYear` of [zonedb](src/ace_time/zonedb) and
3985
[zonedbx](src/ace_time/zonedbx) databases to 10000
4086
* databases now valid over the years `[2000,10000)`
41-
* `zonedbx` adds 75 additional Rules for `kPolicyMorocco` (e.g.
87+
* `zonedbx` adds 75 additional Rules for `kZonePolicyMorocco` (e.g.
4288
zone "Africe/Casablanca") due to the precalculated DST shifts which
4389
are listed in the IANA TZ DB up to the year 2087.
4490
* `zonedb` remains unchanged

DEVELOPER.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Arduino controllers:
185185

186186
An entry in `zone_info.cpp` may refer to a zone policy defined in
187187
`zone_policies.h`. For example, the `kZoneAmerica_Los_Angeles` has a pointer
188-
to a `kPolicyUS` data structure which is defined in `zone_policies.h`.
188+
to a `kZonePolicyUS` data structure which is defined in `zone_policies.h`.
189189

190190
Each policy entry starts with a comment secion that contains some metadata
191191
about the policy. For example:
@@ -304,16 +304,16 @@ The call stack of the first method looks like this:
304304
```
305305
ZoneDateTime::forComponents()
306306
-> TimeZone::getOffsetDateTime(LocalDateTime&)
307-
-> ExtendeZoneProcessor::getOffsetDateTime(LocalDateTime&)
307+
-> ExtendeZoneProcessor::findByLocalDateTime(LocalDateTime&)
308308
-> TransitionStorage::findTransitionForDateTime(LocalDateTime&)
309309
```
310310

311311
The call stack of the second method looks like this:
312312

313313
```
314314
ZoneDateTime::forEpochSeconds(acetime_t)
315-
-> TimeZone::getUtcOffset(acetime_t)
316-
-> ExtendedZoneProcessor::getUtcOffset(acetime_t)
315+
-> TimeZone::getOffsetDateTime(acetime_t)
316+
-> ExtendedZoneProcessor::findByEpochSeconds(acetime_t)
317317
-> TransitionStorage::findTransitionForSeconds(acetime_t)
318318
```
319319

@@ -352,7 +352,7 @@ the prior year after the correct UTC offset is calculated, so we need to pick up
352352
Transitions in the prior year. Similarly, a local date time of Dec 31 could land
353353
in the following year after correcting for UTC offset.
354354

355-
A `MatchingEra` is a wrapper around a `ZoneEra`, with its startDateTimea and
355+
A `MatchingEra` is a wrapper around a `ZoneEra`, with its startDateTime and
356356
untilDateTime truncated to be within the 14-month interval of interest.
357357

358358
<a name="Step2CreateTransitions"></a>

MIGRATING.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Table of Contents
44

5+
* [Migrating to v2.1.0](#MigratingToVersion210)
6+
* [Unified Links](#UnifiedLinks)
7+
* [ZonedExtra](#ZonedExtra)
58
* [Migrating to v2.0.0](#MigratingToVersion200)
69
* [High Level](#HighLevel200)
710
* [Details](#Details200)
@@ -15,6 +18,89 @@
1518
* [Migrating the DS3231Clock](#MigratingTheDS3231Clock)
1619
* [Migrating to LinkManagers](#MigratingToLinkManagers)
1720

21+
<a name="MigratingToVersion210"></a>
22+
## Migrating to v2.1
23+
24+
<a name="UnifiedLinks"></a>
25+
### Unified Links
26+
27+
Over the years, I implemented 4 different versions of the Link entries:
28+
29+
* Ghost Links (`< v1.5`)
30+
* Fat Links (`>= v1.5`)
31+
* Thin Links (`>= v1.6`)
32+
* Symbolic Links (`>= v1.11`)
33+
34+
I had mistakenly assumed that TZDB Link entries were somehow less important
35+
than the Zone entries. Often Link entries were old spellings of
36+
zones which were replaced by new zone names (e.g. "Asia/Calcutta" replaced by
37+
"Asia/Kolkata"), or zones using an older naming convention pre-1993 (e.g.
38+
"UTC" replaced by "Etc/UTC").
39+
40+
The code in AceTime reflected my assumption of the second-class status of Link
41+
entries. Recently however the IANA TZDB project has aggressively merged
42+
unrelated Zones (in different countries) into a single zone if they all happen
43+
to have the same DST transition rules since 1970. The duplicate zones become
44+
Link entries to the "canonical" zone (e.g. "Arctic/Longyearbyen",
45+
"Europe/Copenhagen", "Europe/Oslo", "Europe/Stockholm", "Atlantic/Jan_Mayen" are
46+
all links to "Europe/Berlin").
47+
48+
It is now more clear the Link entries should be considered first-class entries,
49+
just like Zone entries. The v2.1 release implements this change in semantics.
50+
All previous implementations of Links are now merged into a single
51+
implementation which treats Links equal to Zones, and all the usual operations
52+
on Zones are also valid on Links.
53+
54+
1) The "Thin Link" feature has been removed, along with the Link Manager
55+
classes. The code was too complex, and did not provide enough value.
56+
* `LinkManager`
57+
* `BasicLinkManager`
58+
* `ExtendedLinkManager`.
59+
2) The `followLink` parameter on various `TimeZone` and `ZoneProcessor` methods
60+
has been removed.
61+
3) The `zonedb` and `zonedbx` databases no longer contain the link registries:
62+
* `basic::kLinkRegistry`
63+
* `extended::kLinkRegistry`
64+
4) The `kZoneRegistry` is still generated for historical reasons.
65+
* This registry contains the minimum complete dataset of the IANA timezones.
66+
* Most applications should use `kZoneAndLinkRegistry` which contains the
67+
Link entries.
68+
69+
Most application code are expected to treat Links and Zones equally. There are
70+
only 2 methods which apply only to Link time zones:
71+
72+
* `TimeZone::isLink()`
73+
* Returns true if the current time zone is a Link.
74+
* `TimeZone::printTargetZoneNameTo()`
75+
* Prints the name of the target Zone if the current zone is a link.
76+
* It prints nothing is `isLink()` is false.
77+
78+
<a name="ZonedExtra"></a>
79+
### ZonedExtra
80+
81+
The `ZonedExtra` class was created to replace 3 ad-hoc query methods on the
82+
`TimeZone` object:
83+
84+
* Removed: `TimeZone::getUtcOffset()`
85+
* Removed: `TimeZone::getDeltaOffset()`
86+
* Removed: `TimeZone::getAbbrev()`
87+
88+
Once the `ZonedExtra` object has been objected for a particular point in time,
89+
the following methods on `ZonedExtra` are the replacements for the above:
90+
91+
* `ZonedExtra::timeOffset()`
92+
* `ZonedExtra::dstOffset()`
93+
* `ZonedExtra::abbrev()`
94+
95+
The `ZonedExtra` object will normally be created through 2 factory methods:
96+
97+
* `ZonedExtra::forEpochSeconds(epochSeconds, tz)`
98+
* `ZonedExtra::forLocalDateTime(ldt, tz)`
99+
100+
The `ZonedExtra` object provides access to other meta-information about the time
101+
zone at that particular time. See the [ZonedExtra](USER_GUIDE.md#ZonedExtra)
102+
section in the `USER_GUIDE.md` for more detailed information about this class.
103+
18104
<a name="MigratingToVersion200"></a>
19105
## Migrating to v2.0
20106

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@ This library can be an alternative to the Arduino Time
5252
(https://github.com/PaulStoffregen/Time) and Arduino Timezone
5353
(https://github.com/JChristensen/Timezone) libraries.
5454

55-
**Breaking Changes in v2.0**: 1) The default AceTime epoch is shifted forward
56-
from 2000-01-01 (v1) to 2050-01-01 (v2). This extends the validity of most
57-
timezone related functions from `[2000,2050)` to `[2000,2100)`. 2) The epoch
58-
year is now an adjustable parameter using the `Epoch::currentEpochYear(year)`
59-
function. 3) The zoneinfo databases (`zonedb` and `zonedbx`) are now valid from
60-
`[2000, 10000)`, independent of the current epoch year. See the [Migrating to
61-
v2.0.0](MIGRATING.md#MigratingToVersion200) section for more details.
55+
**Breaking Changes in v2.1**: Links are now first-class citizens compared to
56+
Zones and should be treated exactly the same. Fat link and symbolic link
57+
implementations have been unified. The `kZoneRegistry` and
58+
`kZoneAndLinkRegistry` are identical. Only 2 methods are special to Link time
59+
zones: `TimeZone::isLink()` and `TimeZone::printTargetNameTo()`. See [Migrating
60+
to v2.1.0](MIGRATING.md#MigratingToVersion210) section for more details.
6261

63-
**Version**: 2.0.1 (2022-12-04, TZDB version 2022g)
62+
**Version**: 2.1.0 (2023-01-29, TZDB version 2022g)
6463

6564
**Changelog**: [CHANGELOG.md](CHANGELOG.md)
6665

@@ -274,8 +273,9 @@ void setup() {
274273
Serial.println();
275274

276275
// Print the current time zone abbreviation, e.g. "PST" or "PDT"
276+
ZonedExtra ze = losAngelesTz.getZonedExtra(epochSeconds);
277277
Serial.print(F("Abbreviation: "));
278-
Serial.print(losAngelesTz.getAbbrev(epochSeconds));
278+
SERIAL_PORT_MONITOR.print(ze.abbrev());
279279
Serial.println();
280280

281281
// Create from epoch seconds. London is still on standard time.
@@ -293,8 +293,9 @@ void setup() {
293293
Serial.println();
294294

295295
// Print the current time zone abbreviation, e.g. "GMT" or "BST"
296+
ze = londonTz.getZonedExtra(epochSeconds);
296297
Serial.print(F("Abbreviation: "));
297-
Serial.print(londonTz.getAbbrev(epochSeconds));
298+
SERIAL_PORT_MONITOR.print(ze.abbrev());
298299
Serial.println();
299300

300301
Serial.println(F("=== Compare ZonedDateTime"));
@@ -1129,9 +1130,8 @@ and
11291130
[ExtendedHinnantDateTest](https://github.com/bxparks/AceTimeValidation/tree/master/ExtendedHinnantDateTest)
11301131
validation tests which compare the AceTime algorithms to the Hinnant Date
11311132
algorithms. For all times zones between the years 2000 until 2100, the AceTime
1132-
UTC offsets (`TimeZone::getUtcOffset()`), timezone abbreviations
1133-
(`TimeZone::getAbbrev()`), and epochSecond conversion to date components
1134-
(`ZonedDateTime::fromEpochSeconds()`) match the results from the Hinnant Date
1133+
date-time components (`ZonedDateTime`) and abbreviations (`ZonedExtra`)
1134+
calculated from the given epochSeconds match the results from the Hinnant Date
11351135
libraries.
11361136
11371137
<a name="Cctz"></a>

0 commit comments

Comments
 (0)