Skip to content

Commit 27a4053

Browse files
authored
Merge pull request #65 from bxparks/develop
merge v1.7.2 into master
2 parents 1f8bddc + 062360d commit 27a4053

File tree

535 files changed

+5294
-4508
lines changed

Some content is hidden

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

535 files changed

+5294
-4508
lines changed

CHANGELOG.md

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

33
* Unreleased
4+
* 1.7.2 (2021-06-02)
5+
* **Bug Fix**: Add `ZonedDateTime::normalize()`, which must be called by
6+
the client code after calling a `ZonedDateTime` mutation function.
7+
* See [ZonedDateTime Normalization](docs/date_time_timezone.md#ZonedDateTimeNormalization).
8+
* Increases flash usage by 222 bytes by making this single call on an
9+
AVR unfortunately.
10+
* Migrate `PrintStr::getCstr()` in AceCommon <=1.4.4 to the shorter
11+
`PrintStr::cstr()` in AceCommon >= 1.4.5.
12+
* Migrate to AceRoutine v1.3.1, which changes
13+
`AceRoutine::coroutineMillis()` into non-virtual.
14+
* Change `SystemClock` to instantiate from `SystemClockTemplate`, which
15+
allows `SystemClock::clockMillis()` to also become non-virtual. Saves
16+
20-40 bytes of flash. No discernible changes in CPU time.
417
* 1.7.1 (2021-04-02)
518
* Simplify calculation of `SystemClock::getSecondsSinceSyncAttempt()`
619
and `SystemClock::getSecondsToSyncAttempt()`, which substantially

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ This library can be an alternative to the Arduino Time
4040
(https://github.com/PaulStoffregen/Time) and Arduino Timezone
4141
(https://github.com/JChristensen/Timezone) libraries.
4242

43-
**Version**: 1.7.1 (2021-04-02, TZ DB version 2021a)
43+
**Version**: 1.7.2 (2021-06-02, TZ DB version 2021a)
4444

4545
**Changelog**: [CHANGELOG.md](CHANGELOG.md)
4646

@@ -75,7 +75,7 @@ installation instructions.
7575
* [Tool Chain](#ToolChain)
7676
* [Operating System](#OperatingSystem)
7777
* [License](#License)
78-
* [Feedback and Support](#FeedbackSupport)
78+
* [Feedback and Support](#FeedbackAndSupport)
7979
* [Authors](#Authors)
8080

8181
<a name="Overview"></a>
@@ -563,15 +563,17 @@ See [docs/installation.md](docs/installation.md).
563563

564564
* [README.md](README.md)
565565
* this file
566-
* [docs/date_time_timezone.md](docs/date_time_timezone.md)
566+
* Date, Time and TimeZones
567+
([docs/date_time_timezone.md](docs/date_time_timezone.md))
567568
* Date and Time classes
568569
* TimeZone classes
569570
* ZoneInfo Database
570571
* Mutations
571572
* Error Handling
572573
* Motivation and Design Considerations
573574
* Bugs and Limitations
574-
* [docs/clock_system_clock.md](docs/clock_system_clock.md)
575+
* Clocks and SystemClocks
576+
([docs/clock_system_clock.md](docs/clock_system_clock.md))
575577
* Clock
576578
* NTP Clock, DS3231 Clock, STM32 RTC Clock, STM32F1 Clock
577579
* SystemClock, SystemClockLoop, SystemClockCoroutine
@@ -655,7 +657,7 @@ them.
655657

656658
[MIT License](https://opensource.org/licenses/MIT)
657659

658-
<a name="FeedbackSupport"></a>
660+
<a name="FeedbackAndSupport"></a>
659661
## Feedback and Support
660662

661663
If you find this library useful, consider starring this project on GitHub. The

docs/clock_system_clock.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sense for these classes to be in a separate library because the other parts of
1212
AceTime library are not dependent of the Clock classes. But for now, these
1313
classes live within the AceTime library.
1414

15-
**Version**: 1.7.1 (2021-04-02, TZ DB version 2021a)
15+
**Version**: 1.7.2 (2021-06-02, TZ DB version 2021a)
1616

1717
## Table of Contents
1818

@@ -49,7 +49,7 @@ classes live within the AceTime library.
4949
## Overview
5050

5151
The main purpose of the `Clock` classes in this module is to provide a 32-bit
52-
signed integer (`acetime_t` typedefed to `int32_t`) that represents the number
52+
signed integer (`acetime_t` typedef'ed to `int32_t`) that represents the number
5353
of seconds since a fixed point in the past called the "Epoch". The AceTime Epoch
5454
is defined to be 2000-01-01 00:00:00 UTC.
5555

@@ -190,7 +190,7 @@ API, but subclasses are expected to provide the non-blocking interface when
190190
needed.
191191

192192
The `acetime_t` value from `getNow()` can be converted into the desired time
193-
zone using the `ZonedDateTime` and `TimeZone` classes desribed in the previous
193+
zone using the `ZonedDateTime` and `TimeZone` classes described in the previous
194194
sections.
195195

196196
<a name="NtpClock"></a>
@@ -278,7 +278,7 @@ you delete the commit, they can be retrieved from the git history.
278278
## DS3231 Clock
279279

280280
The `DS3231Clock` class uses the DS3231 RTC chip. It contains an internal
281-
temperature-compensated osciallator that counts time in 1 second steps. It is
281+
temperature-compensated oscillator that counts time in 1 second steps. It is
282282
often connected to a battery or a supercapacitor to survive power failures. The
283283
DS3231 chip stores the time broken down by various date and time components
284284
(i.e. year, month, day, hour, minute, seconds). It contains internal logic that
@@ -521,7 +521,7 @@ class SystemClock: public Clock {
521521

522522
Clock* getReferenceClock() const { return mReferenceClock; }
523523

524-
virtual unsigned long clockMillis() const { return ::millis(); }
524+
unsigned long clockMillis() const { return ::millis(); }
525525

526526
void keepAlive();
527527

docs/date_time_timezone.md

Lines changed: 73 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ following namespaces:
1212
`ExtendedZoneManager`
1313
* `ace_time::internal`: not normally needed by app developers
1414

15-
**Version**: 1.7.1 (2021-04-02, TZ DB version 2021a)
15+
**Version**: 1.7.2 (2021-06-02, TZ DB version 2021a)
1616

1717
## Table of Contents
1818

@@ -62,6 +62,7 @@ following namespaces:
6262
* [TimeOffset Mutations](#TimeOffsetMutations)
6363
* [LocalDate Mutations](#LocalDateMutations)
6464
* [ZonedDateTime Mutations](#ZonedDateTimeMutations)
65+
* [ZonedDateTime Normalization](#ZonedDateTimeNormalization)
6566
* [TimePeriod Mutations](#TimePeriodMutations)
6667
* [Error Handling](#ErrorHandling)
6768
* [isError()](#IsError)
@@ -82,7 +83,7 @@ following namespaces:
8283
The Date, Time, and TimeZone classes provide an abstraction layer to make it
8384
easier to use and manipulate date and time fields, in different time zones. It
8485
is difficult to organize the various parts of this library in the most easily
85-
digestable way, but perhaps they can be categorized into three parts:
86+
digestible way, but perhaps they can be categorized into three parts:
8687

8788
* Simple Date and Time classes for converting date and time fields to and
8889
from the "epoch seconds",
@@ -1820,7 +1821,7 @@ const basic::ZoneInfo* zoneInfo = ...;
18201821
PrintStr<32> printStr; // buffer of 32 bytes on the stack
18211822
BasicZone(zoneInfo).printNameTo(printStr);
18221823

1823-
const char* name = printStr.getCstr();
1824+
const char* name = printStr.cstr();
18241825
// do stuff with 'name', but only while 'printStr' is alive
18251826
...
18261827
```
@@ -2065,7 +2066,7 @@ which prints to the serial port.
20652066
The AceCommon library (https://github.com:bxparks/AceCommon) provides a
20662067
subclass of `Print` called `PrintStr` which allows printing to an in-memory
20672068
buffer. The contents of the in-memory buffer can be retrieved as a normal
2068-
c-string using the `PrintStr::getCstr()` method.
2069+
c-string using the `PrintStr::cstr()` method.
20692070
20702071
Instances of the `PrintStr` object is expected to be created on the stack. The
20712072
object will be destroyed automatically when the stack is unwound after returning
@@ -2089,7 +2090,7 @@ using namespace ace_time;
20892090
20902091
PrintStr<32> printStr; // 32-byte buffer
20912092
dt.printTo(printStr);
2092-
const char* cstr = printStr.getCstr();
2093+
const char* cstr = printStr.cstr();
20932094
20942095
// do stuff with cstr...
20952096
@@ -2114,10 +2115,12 @@ the code size increased by 500-700 bytes, which I could not afford because the
21142115
program takes up almost the entire flash memory of an Ardunio Pro Micro with
21152116
only 28672 bytes of flash memory.
21162117

2117-
Most date and time classes in the AceTime library are mutable. The mutation
2118-
operations are not implemented within the class itself to avoid bloating
2119-
the class API surface. The mutation functions live as functions in separate
2120-
namespaces outside of the class definitions:
2118+
Most date and time classes in the AceTime library are mutable. Except for
2119+
primitive mutations of setting specific fields (e.g.
2120+
`ZonedDateTime::year(uint16_t)`), most higher-level mutation operations are not
2121+
implemented within the class itself to avoid bloating the class API surface. The
2122+
mutation functions live as functions in separate namespaces outside of the class
2123+
definitions:
21212124

21222125
* `time_period_mutation.h`
21232126
* `time_offset_mutation.h`
@@ -2145,8 +2148,12 @@ increment the `ZonedDateTime::day()` field from Feb 29 to Feb 30, then to Feb
21452148
converted into an Epoch seconds (using `toEpochSeconds()`), then converted back
21462149
to a `ZonedDateTime` object (using `forEpochSeconds()`). By deferring this
21472150
normalization step until the user has finished setting all the clock fields, we
2148-
can reduce the size of the code in flash. (The limiting factor for many Arduino
2149-
environments is the code size, not the CPU time.)
2151+
can reduce the size of the code in flash. (The limiting factor for many 8-bit
2152+
Arduino environments is the code size, not the CPU time.)
2153+
2154+
Mutating the `ZonedDateTime` requires calling the `ZonedDateTime::normalize()`
2155+
method after making the changes. See the subsection on [ZonedDateTime
2156+
Normalization](#ZonedDateTimeNormalization) below.
21502157

21512158
It is not clear that making the AceTime objects mutable was the best design
21522159
decision. But it seems to produce far smaller code sizes (hundreds of bytes of
@@ -2161,6 +2168,9 @@ The `TimeOffset` object can be mutated with:
21612168

21622169
```C++
21632170
namespace ace_time {
2171+
2172+
void setMinutes(int16_t minutes) {
2173+
21642174
namespace time_offset_mutation {
21652175

21662176
void increment15Minutes(TimeOffset& offset);
@@ -2172,10 +2182,15 @@ void increment15Minutes(TimeOffset& offset);
21722182
<a name="LocalDateMutations"></a>
21732183
### LocalDate Mutations
21742184
2175-
The `LocalDate` object can be mutated with the following methods:
2185+
The `LocalDate` object can be mutated with the following methods and functions:
21762186
21772187
```C++
21782188
namespace ace_time {
2189+
2190+
void LocalDate::year(int16_t year);
2191+
void LocalDate::month(uint8_t month);
2192+
void LocalDate::day(uint8_t month);
2193+
21792194
namespace local_date_mutation {
21802195
21812196
void incrementOneDay(LocalDate& ld);
@@ -2188,10 +2203,20 @@ void decrementOneDay(LocalDate& ld);
21882203
<a name="ZonedDateTimeMutations"></a>
21892204
### ZonedDateTime Mutations
21902205

2191-
The `ZonedDateTime` object can be mutated using the following methods:
2206+
The `ZonedDateTime` object can be mutated using the following methods and
2207+
functions:
21922208

21932209
```C++
21942210
namespace ace_time {
2211+
2212+
void ZonedDateTime::year(int16_t year);
2213+
void ZonedDateTime::month(uint8_t month);
2214+
void ZonedDateTime::day(uint8_t month);
2215+
void ZonedDateTime::hour(uint8_t hour);
2216+
void ZonedDateTime::minute(uint8_t minute);
2217+
void ZonedDateTime::second(uint8_t second);
2218+
void ZonedDateTime::timeZone(const TimeZone& timeZone);
2219+
21952220
namespace zoned_date_time_mutation {
21962221

21972222
void incrementYear(ZonedDateTime& dateTime);
@@ -2204,13 +2229,48 @@ void incrementMinute(ZonedDateTime& dateTime);
22042229
}
22052230
```
22062231

2232+
<a name="ZonedDateTimeNormalization"></a>
2233+
### ZonedDateTimeNormalization
2234+
2235+
When the `ZonedDateTime` object is mutated using the methods and functions
2236+
listed above, the client code must call `ZonedDateTime::normalize()` before
2237+
calling a method that calculates derivative information, in particular, the
2238+
`ZonedDateTime::toEpochSeconds()` method. Otherwise, the resulting epochSeconds
2239+
may be incorrect if the old `ZonedDateTime` and the new `ZonedDatetime` crosses
2240+
a DST boundary. Multiple mutations can be batched before calling
2241+
`normalize()`.
2242+
2243+
For example:
2244+
2245+
```C++
2246+
2247+
TimeZone tz = ...;
2248+
ZonedDateTime zdt = ZonedDateTime::forComponent(2000, 1, 1, 0, 0, 0, tz);
2249+
2250+
zdt.year(2021);
2251+
zdt.month(4);
2252+
zdt.day(20);
2253+
zdt.normalize();
2254+
acetime_t newEpochSeconds = zdt.toEpochSeconds();
2255+
```
2256+
2257+
Adding this single call to `normalize()` seems to increase flash consumption by
2258+
220 bytes on an 8-bit AVR processor. Unfortunately, it must be called to ensure
2259+
accuracy across DST boundaries.
2260+
22072261
<a name="TimePeriodMutations"></a>
22082262
### TimePeriod Mutations
22092263

22102264
The `TimePeriod` can be mutated using the following methods:
22112265

22122266
```C++
22132267
namespace ace_time {
2268+
2269+
void TimePeriod::hour(uint8_t hour);
2270+
void TimePeriod::minute(uint8_t minute);
2271+
void TimePeriod::second(uint8_t second);
2272+
void TimePeriod::sign(int8_t sign);
2273+
22142274
namespace time_period_mutation {
22152275

22162276
void negate(TimePeriod& period);

docs/doxygen.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "AceTime"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 1.7.1
41+
PROJECT_NUMBER = 1.7.2
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

docs/html/AceTime_8h_source.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<tr style="height: 56px;">
2323
<td id="projectalign" style="padding-left: 0.5em;">
2424
<div id="projectname">AceTime
25-
&#160;<span id="projectnumber">1.7.1</span>
25+
&#160;<span id="projectnumber">1.7.2</span>
2626
</div>
2727
<div id="projectbrief">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.</div>
2828
</td>
@@ -137,8 +137,8 @@
137137
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; </div>
138138
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; </div>
139139
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160;<span class="comment">// Version format: xxyyzz == &quot;xx.yy.zz&quot;</span></div>
140-
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160;<span class="preprocessor">#define ACE_TIME_VERSION 10701</span></div>
141-
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160;<span class="preprocessor">#define ACE_TIME_VERSION_STRING &quot;1.7.1&quot;</span></div>
140+
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160;<span class="preprocessor">#define ACE_TIME_VERSION 10702</span></div>
141+
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160;<span class="preprocessor">#define ACE_TIME_VERSION_STRING &quot;1.7.2&quot;</span></div>
142142
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160; </div>
143143
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160;<span class="preprocessor">#endif</span></div>
144144
</div><!-- fragment --></div><!-- contents -->

docs/html/BasicBrokers_8cpp_source.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<tr style="height: 56px;">
2323
<td id="projectalign" style="padding-left: 0.5em;">
2424
<div id="projectname">AceTime
25-
&#160;<span id="projectnumber">1.7.1</span>
25+
&#160;<span id="projectnumber">1.7.2</span>
2626
</div>
2727
<div id="projectbrief">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.</div>
2828
</td>

docs/html/BasicBrokers_8h.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<tr style="height: 56px;">
2323
<td id="projectalign" style="padding-left: 0.5em;">
2424
<div id="projectname">AceTime
25-
&#160;<span id="projectnumber">1.7.1</span>
25+
&#160;<span id="projectnumber">1.7.2</span>
2626
</div>
2727
<div id="projectbrief">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.</div>
2828
</td>

docs/html/BasicBrokers_8h_source.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<tr style="height: 56px;">
2323
<td id="projectalign" style="padding-left: 0.5em;">
2424
<div id="projectname">AceTime
25-
&#160;<span id="projectnumber">1.7.1</span>
25+
&#160;<span id="projectnumber">1.7.2</span>
2626
</div>
2727
<div id="projectbrief">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.</div>
2828
</td>

0 commit comments

Comments
 (0)