Converting discrete to epoch function?

I'm collecting sensor data that contains separate bytes for sec,min,hr,dom,mo (year is assumed). Instead of sending all those bytes off to InitialState with each record, I'd like to convert to an epoch stamp. Is there a code snippet (function) available that will do this for me?

If I remember reading it right epoch is a 32 bit number so I'm assuming that the conversion will save me 2 bytes of data transfer.

Comments

  • Is there any reason you can't just use time()? That's a UNIX epoch value... or is this timestamp coming from another system?
  • Yes. The time I'm talking about is generated at the remote sensors and archived there for several minutes before being burst out to the base (which contains the imp). The sensor processor does not do 'time' but gets it from an RTC.
  • If I remember reading it right epoch is a 32 bit number so I'm assuming that the conversion will save me 2 bytes of data transfer.
    Only until 2038...
  • I was hoping someone had already coded this conversion. I'll look up the particulars and code it myself. So in 2038 does it go to 64 bits? or 40 bits?
  • I'm pretty sure @aron had one at some point? @aron?

    In 2038 a lot of stuff will break - it's far more problematic than Y2K was. See https://en.wikipedia.org/wiki/Year_2038_problem

    Significantly before then, we'll move imps to 64 bit time, I would suspect! The internal RTC in imp1/2/3/4 are calendar based vs a 32 bit register.
Sign In or Register to comment.