Skip to content

saving DateTime object's memory#4

Open
solamyl wants to merge 5 commits into
hideakitai:masterfrom
solamyl:master
Open

saving DateTime object's memory#4
solamyl wants to merge 5 commits into
hideakitai:masterfrom
solamyl:master

Conversation

@solamyl

@solamyl solamyl commented Dec 24, 2025

Copy link
Copy Markdown

Hi Hideaki,
I was looking for some DS3231 library and found yours. In the end I didn't use it but I used the DataTime class which I have found handy :-)

BUT: unfortunately there were some unpleasant imperfections which I have fixed in this patch.

Changes:

  • reduced memory footprint from 18 => 6 bytes per object. You know, I am using Arduino Nano and need to save every byte. I needed that for storing lot of DateTimes in my embed device
  • added "trivial" default constructor - sometimes it is called pretty often and it is good practice to have it
  • added assignment operators
  • added const to the methods where was missing

There were no functional changes.
I have tested it against all examples and with my code and is working fine.

thank you in advance,
-- stepan

reduced sizeof(DateTime) object from 18 bytes => 6 bytes.
definition of `daysInMonth` array must be in separate .cpp file, otherwise its content is copied into each class instance.
it is always good practice to have the default constructor as minimal as possible.
Constructor DateTime(uint32_t) is too complex.
with these simple and straightforward  classes it makes no sense to have a copy constructor but do not have assignment operator
added const to the methods where missing
datatypes uint8/16/32_t declared in Wire.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants