[En-Nut-Discussion] Fwd: RTC function reciprocal
Henrik Maier
hmlists at focus-sw.com
Tue Dec 20 20:49:55 CET 2005
The Dallas/Maxim Application Note 517 covers this topic and publishes
the following routine:
unsigned long DS1371_DateToBinary(tm_struct *datetime) {
unsigned long iday;
unsigned long val;
iday = 365 * (datetime->tm_year - 70) + DaysToMonth[datetime->tm_mon] +
(datetime->tm_mday - 1);
iday = iday + (datetime->tm_year - 69) / 4;
if ((datetime->tm_mon > 1) && ((datetime->tm_year % 4) == 0)) {
iday++;
}
val = datetime->tm_sec + 60 * datetime->tm_min + 3600 *
(datetime->tm_hour + 24 * iday);
return val;
}
The full code can be obtained from:
ftp://ftp.dalsemi.com/pub/timekeeping/DS1371/
Henrik Maier
Harald Kipp wrote:
> Forwarded to the list:
>
>
>> Date: Tue, 20 Dec 2005 08:08:54 +1000
>> From: Don Ingram
>>
>> Hi All,
>>
>> Would anyone have some code close at hand to provide the reciprocal of
>> the
>> localtime_r() function so that we can convert a _tm time struct to
>> seconds to
>> set the nut time.
>>
>> Not so much lazy as very stretched for time ;-)
>>
>> --
>> Cheers & thanks
>>
>> Don
>>
>>
>
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>
>
>
More information about the En-Nut-Discussion
mailing list