PaulStoffregen / Time

Time library for Arduino
http://playground.arduino.cc/code/time
1.25k stars 666 forks source link

Suggestion: break up files for functions not dependent on Arduino #100

Open bootchk opened 6 years ago

bootchk commented 6 years ago

makeTime and breakTime are useful in themselves, as substitutes for the C std time library. But when I tried to use the libraries, they depend on WProgram.h an Arduino header. Could you break them out into a separate file?

My context is I have an RTC chip that delivers a calendar time. I want Unix epoch time (really even simpler than that) and to use makeTime and breakTime for conversions back and forth.

Thanks for your work and please excuse that this is not a bug.

bootchk commented 6 years ago

Also, there are some comments in makeTime and breakTime about the offset from 1970. AFAIK, the conversions "work" in that they are reversible, regardless of any chosen epoch time e.g. the "Unix epoch time", 1970 00:00:00. It does seem that other parts of the library require use of the Unix epoch time.

My use case is an external RTC chip, because it is so much more low power than the RTC built into the mcu or implemented in software. I don't even care to set the RTC ( to sidereal time). The epoch time is just when the RTC is powered up. I use conversions so I can do simple integer math on time_t.

No big deal, I extracted the routines easily enough.