Skip to content

Commit 4ccf8f5

Browse files
committed
USER_GUIDE.md: rewrite for better flow
1 parent 9bb33cc commit 4ccf8f5

File tree

2 files changed

+52
-53
lines changed

2 files changed

+52
-53
lines changed

README.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,33 @@
66
The AceTime library provides Date, Time, and TimeZone classes which can convert
77
"epoch seconds" from the AceTime Epoch (default 2050-01-01 UTC) to
88
human-readable local date and time fields. Those classes can also convert local
9-
date and time between different time zones, properly accounting for all DST
10-
transitions from the year 2000 until 2100. The library has mechanisms to extend
11-
the range of useful years.
9+
date and time between different time zones defined by the [IANA TZ
10+
database](https://www.iana.org/time-zones) while accurately accounting for DST
11+
transitions.
1212

1313
The default AceTime epoch is 2050-01-01, but it can be adjusted by the client
1414
application at runtime. The epoch second has the type `acetime_t` which is a
1515
32-bit signed integer, instead of a 64-bit signed integer. Using the smaller
16-
32-bit integer allows the library to be efficient on 8-bit and 32-bit
17-
microcontrollers with limited memory resources, and without native 64-bit
18-
integer instructions. The range of a 32-bit signed integer is about 136 years.
19-
AceTime timezone functions will be valid at a minimum over a 100-year interval
20-
straddling +/- 50 years of the `Epoch::currentEpochYear()`, subject to the
21-
accuracy limits of the given ZoneInfo Database. In practice, the range of
22-
validity is probably at least +/- 60 years, or even +/- 65 years, but boundary
23-
effects at the larger intervals are more likely.
24-
25-
The library provides 3 pre-generated ZoneInfo Databases which
26-
are programmatically extracted from the [IANA TZ
27-
database](https://www.iana.org/time-zones):
28-
29-
- [zonedb](src/zonedb) (basic, not usually recommended)
30-
- valid over the years `[2000,10000)`
16+
32-bit integer allows the library to use less CPU and memory resources on 8-bit
17+
and 32-bit microcontrollers without native 64-bit integer instructions. The
18+
range of a 32-bit integer is about 136 years. To be safe, AceTime timezone
19+
functions should be kept well within the bounds of this interval, for example,
20+
straddling roughly +/- 60 years of the `Epoch::currentEpochYear()`.
21+
22+
The library provides 3 pre-generated ZoneInfo Databases which are
23+
programmatically extracted from the IANA TZ database:
24+
25+
- [zonedb](src/zonedb) ("basic", not usually recommended)
26+
- accurate over the years `[2000,10000)`
3127
- contains a subset of zones (~450) compatible with `BasicZoneProcessor`
3228
and `BasicZoneManager`
33-
- [zonedbx](src/zonedbx) (extended, recommended for most situations)
34-
- valid over the years `[2000,10000)`
29+
- [zonedbx](src/zonedbx) ("extended", recommended for most situations)
30+
- accurate over the years `[2000,10000)`
3531
- contains all zones and links (~600) in the IANA TZ database
3632
- compatible with `ExtendedZoneProcessor` and `ExtendedZoneManager`
37-
- [zonedbc](src/zonedbc) (complete, mostly for validation testing, new in v2.3)
38-
- valid over the years `[0001,10000)`
33+
- [zonedbc](src/zonedbc) ("complete", mostly intended for validation testing,
34+
new in v2.3)
35+
- accurate over the years `[0001,10000)`
3936
- contains all zones and links (~600) the IANA TZ database
4037
- compatible with `CompleteZoneProcessor` and `CompleteZoneManager`
4138

USER_GUIDE.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ sets the epoch to be `{year}-01-01T00:00:00 UTC`.
99
The epoch seconds is represented by an `int32_t` integer (instead of an
1010
`int64_t` used in most modern timezone libraries) to save resources on 8-bit
1111
processors without native 64-bit integer instructions. The range of a 32-bit
12-
integer is about 132 years which allows most features of the AceTime library to
13-
work across at least a 100-year (probably as large as 120-year) interval
14-
straddling the current epoch year.
12+
integer is about 136 years which allows most features of the AceTime library to
13+
work across at least about a 120-year interval straddling the current epoch
14+
year.
1515

16-
The IANA TZ database is programmatically generated into the `src/zonedb`,
17-
`src/zonedbx`, and `src/zonedbc` subdirectories from the raw IANA TZ files. The
18-
database entries are valid from the years `[2000,10000)` (`zonedb`, `zonedbx`)
19-
or `[0001,10000)` (`zonedbc`). By adjusting the `currentEpochYear()`, the
20-
library will work across any 100-120 year interval straddling the current epoch
21-
year, across the 8000 to 10000 year range of the TZ database.
16+
The IANA TZ database is programmatically generated into 3 predefined databases:
17+
`src/zonedb`, `src/zonedbx`, and `src/zonedbc` subdirectories. Different
18+
databases have different accuracy ranges, and are designed to work with
19+
different `ZoneProcessor` and `ZoneManager` classes.
2220

2321
**Version**: 2.3.0 (2023-06-27, TZDB 2023c)
2422

@@ -102,20 +100,23 @@ year, across the 8000 to 10000 year range of the TZ database.
102100

103101
The Date, Time, and TimeZone classes provide an abstraction layer to make it
104102
easier to use and manipulate date and time fields, in different time zones. It
105-
is difficult to organize the various parts of this library in the most easily
103+
is difficult to organize the various parts of this library in an easily
106104
digestible way, but perhaps they can be categorized into three parts:
107105

108106
* Simple Date and Time classes for converting date and time fields to and
109-
from the "epoch seconds",
110-
* TimeZone related classes which come in 2 forms:
111-
* classes that extend the simple Date and Time classes that account for time
112-
zones which can be described in a time zone database (e.g. `TimeZone`,
113-
`ZonedDateTime`, `ZoneProcessor`)
114-
* classes and types that manage the TZ Database and provide access to its
115-
data (e.g. `ZoneManager`, `ZoneInfo`, `ZoneId`)
116-
* The ZoneInfo Database generated from the IANA TZ Database that contains UTC
117-
offsets and the rules for determining when DST transitions occur for a
118-
particular time zone
107+
from the "epoch seconds", for example:
108+
- `acetime_t`
109+
- `LocalDate`, `LocalTime`, `LocalDateTime`, `OffsetDateTime`
110+
- `TimeOffset`, `TimePeriod`
111+
* TimeZone related classes, for example:
112+
- `TimeZone`, `ZoneInfo`
113+
- `ZonedDateTime`, `ZonedExtra`
114+
- `BasicZoneProcessor`, `ExtendedZoneProcessor`, `CompleteZoneProcessor`
115+
- `BasicZoneManager`, `ExtendedZoneManager`, `CompleteZoneManager`
116+
* ZoneInfo Databases generated from the IANA TZ Database
117+
* contains UTC offsets and the DST transition rules
118+
* `zonedb/`, `zonedbx/`, `zonedbc/` databases
119+
* registries: `kZoneRegistry`, `kZoneAndLinkRegistry`
119120

120121
<a name="DateAndTimeOverview"></a>
121122
### Date and Time Overview
@@ -158,10 +159,11 @@ Most timezone related functions of the library use the `int32_t` epochseconds
158159
for its internal calculations, so the date range should be constrained to +/- 68
159160
years of the current epoch. The timezone calculations require some additional
160161
buffers at the edges of the range (1-3 years), so the actual range of validity
161-
is about +/- 65 years. To be very conservative, client applications are advised
162-
to limit the date range to about 100 years, in other words, about +/- 50 years
163-
from the current epoch year. Using the default epoch year of 2050, the
164-
recommended range is `[2000,2100)`.
162+
is about +/- 65 years. To be conservative, client applications are advised to
163+
limit the date range to about 100-120 years, in other words, about +/- 50 to 60
164+
years from the current epoch year. Using the default epoch year of 2050, the
165+
recommended range is `[2000,2100)` because a 100-year interval is easy to
166+
remember.
165167

166168
<a name="TimeZoneOverview"></a>
167169
### TimeZone Overview
@@ -223,8 +225,8 @@ Three slightly different sets of ZoneInfo entries are generated:
223225
* contains `kZoneId*` identifiers (e.g. `kZoneIdAfrica_Casablanca`)
224226
* [zonedbc/zone_infos.h](src/zonedbc/zone_infos.h)
225227
* intended for `CompleteZoneProcessor` or `CompleteZoneManager`
226-
* all 596 (as of version 2023c) in the IANA TZ Database
227-
over the vast years of `[0001,10000)`
228+
* all 596 (as of version 2023c) in the IANA TZ Database over the years of
229+
`[0001,10000)`
228230
* contains `kZone*` declarations (e.g. `kZoneAfrica_Casablanca`)
229231
* contains `kZoneId*` identifiers (e.g. `kZoneIdAfrica_Casablanca`)
230232

@@ -337,7 +339,7 @@ with several major differences:
337339
It is possible to convert between a `time_t` and an `acetime_t` by adding or
338340
subtracting the number of seconds between the 2 Epoch dates. This value is given
339341
by `Epoch::secondsToCurrentEpochFromUnixEpoch64()` which returns an `int64_t`
340-
value to allow epoch years greater than 2038. If the date is within +/- 50 years
342+
value to allow epoch years greater than 2038. If the date is within +/- 60 years
341343
of the current epoch year, then the resulting epoch seconds will fit inside a
342344
`int32_t` integer. Helper methods are available on various classes to avoid
343345
manual conversion between these 2 epochs: `forUnixSeconds64()` and
@@ -3344,8 +3346,8 @@ Serial.println(dt.isError() ? "true" : "false");
33443346
dates that can be represented by `acetime_t` is theoretically
33453347
1981-12-13T20:45:53 UTC to 2118-01-20T03:14:07 UTC (inclusive).
33463348
* To be conservative, users of this library should limit the range of the
3347-
epoch seconds to +/- 50 years of the current epoch, in other words,
3348-
`[2000,2100)`.
3349+
epoch seconds to +/- 60 years of the current epoch, in other words,
3350+
`[1990,2110)`, or even easier to remember, `[2000,2100)`.
33493351
* `LocalDate`, `LocalDateTime`
33503352
* The class checks that the `year` component in the range of `[0,
33513353
10000]`, which is a smaller range than the `[-32767,32765]` range
@@ -3390,8 +3392,8 @@ Serial.println(dt.isError() ? "true" : "false");
33903392
as well as it could be, and the algorithm may change in the future. To keep
33913393
the code size within reasonble limits of a small Arduino controller, the
33923394
algorithm may be permanently sub-optimal.
3393-
* `ZonedDateTime` objects should remain within roughly +/- 50 years (maybe +/-
3394-
60 years) of the current AceTime Epoch.
3395+
* `ZonedDateTime` objects should remain within roughly +/- 60 years of the
3396+
current AceTime Epoch.
33953397
* Otherwise, internal integer variables may overflow without warning
33963398
and incorrect results may be calculated.
33973399
* The internal time zone calculations use the same `int32_t` type as the

0 commit comments

Comments
 (0)