@@ -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:
8283The Date, Time, and TimeZone classes provide an abstraction layer to make it
8384easier to use and manipulate date and time fields, in different time zones. It
8485is 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 = ...;
18201821PrintStr<32 > printStr; // buffer of 32 bytes on the stack
18211822BasicZone (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.
20652066The AceCommon library (https://github.com:bxparks/AceCommon) provides a
20662067subclass of `Print` called `PrintStr` which allows printing to an in-memory
20672068buffer. 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
20702071Instances of the `PrintStr` object is expected to be created on the stack. The
20712072object 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
21142115program takes up almost the entire flash memory of an Ardunio Pro Micro with
21152116only 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
21452148converted into an Epoch seconds (using ` toEpochSeconds() ` ), then converted back
21462149to a ` ZonedDateTime ` object (using ` forEpochSeconds() ` ). By deferring this
21472150normalization 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
21512158It is not clear that making the AceTime objects mutable was the best design
21522159decision. 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++
21632170namespace ace_time {
2171+
2172+ void setMinutes(int16_t minutes) {
2173+
21642174namespace time_offset_mutation {
21652175
21662176void 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++
21782188namespace 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+
21792194namespace local_date_mutation {
21802195
21812196void 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++
21942210namespace 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+
21952220namespace zoned_date_time_mutation {
21962221
21972222void 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
22102264The ` TimePeriod ` can be mutated using the following methods:
22112265
22122266``` C++
22132267namespace 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+
22142274namespace time_period_mutation {
22152275
22162276void negate(TimePeriod& period);
0 commit comments