Re: Wallclock - calendar option

Bernard Fouché <[email protected]> Tue, 14 Feb 2012 15:44:50 +0100
Newsgroups gmane.os.ecos.devel
Message-ID <[email protected]>
Le 14/02/2012 12:09, qber_ a écrit :
> Hello all.
> I want to discuss an option of Wallclock device framework.. Now the wallclock supports two option : init_get and set_get. This functions support time counted from 1970-01-01 00:00:00. The idea is to add the support for calendar insted of seconds counter. Most of applications uses calendar not seconds counter.
> The change for handling date and time for me is a result of working with STM32F2x processor which has calendar based RTC. The is no sense for converting calendar to seconds and then back again to calendar.
> The problem is which date and time format should be selected (if this change will be added to officail reposotory).
> Best Regards
> Qber
Hello Qber,

time_t (or any similar integer counter) is used everywhere inside CPUs, 
calendar time is used only to interface with entities externals to the 
MCU/CPU like humans, files/databases, network. Usually there is much 
more internal time calculations than time data output from a CPU in 
calendar representation. It's very hard to see any gain by using 
nightmarish calendar calculations when simple integer arithmetic can be 
used instead. Write a function that adds a variable amount of time to 
data represented as calendar date/time and compare it to an integer 
addition. Conversion functions between time_t and calendar date/time 
exist from 1970-01-01 00:00:00. Even Windows uses an integer 
representation, even probably the Maya as shown by their overflow 
problem at the end of the year.

     Bernard