Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 216600

Forum Post: RE: CCS/MSP430F6721: Problem calculating seconds since epoch from calendar date and time

$
0
0
Just in case someone might be interested, the problem lies where hour * 3600. If hour 18 then somehow resulted value of seconds is 65536 smaller than correct value. I believe this is something related to implementation dependent conversion of int to long. As for now, I use following line to get around it. unsigned long const secondsOfHour = 3600; seconds = second + minute * 60 + hour * secondsOfHour+ dayOfYear * 86400 + (year - 70) * 31536000 + ((year - 69) / 4) * 86400 - ((year - 1) / 100) * 86400 + ((year + 299 ) / 400) * 86400;

Viewing all articles
Browse latest Browse all 216600

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>