Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RtcDateTime vs year below 2000 #60

Closed
Elmaranin opened this issue Feb 16, 2018 · 1 comment
Closed

RtcDateTime vs year below 2000 #60

Elmaranin opened this issue Feb 16, 2018 · 1 comment
Labels

Comments

@Elmaranin
Copy link

Why all these new modern libraries use new format 'since 2000 year'? Most of all old hardware still uses unix-time format 'since 1970..'.

test code that fails:
RtcDateTime test = RtcDateTime(1970, 1, 1, 1, 1, 1);

in RtcDateTime.h:

RtcDateTime(uint16_t year,
uint8_t month,
uint8_t dayOfMonth,
uint8_t hour,
uint8_t minute,
uint8_t second) :
_yearFrom2000((year >= c_OriginYear) ? year - c_OriginYear : year),

how it can convert here
_yearFrom2000((year >= c_OriginYear) ? year - c_OriginYear : year),
1970 for ex, to uint8_t type?
And how can this library at all work correct with data until 2000?
My DS3231 battery is down, when time is readed it correctly returns 1970... zero unix-time, but this RtcDateTime library can't correctly give it to me.
And code in 'DS3231_Simple.ino' fails too in this case:
RtcDateTime now = Rtc.GetDateTime();
if (now < compiled)

@Makuna
Copy link
Owner

Makuna commented Feb 16, 2018

This is by design. These are meant to track current time from a hardware Real Time Clock.

The DS3231 hardware itself cannot even support years before 2000. It stores it as a two digit year offset from 2000. So I have no idea where you get support for 1970 from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants