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;
↧
Forum Post: RE: CCS/MSP430F6721: Problem calculating seconds since epoch from calendar date and time
↧