avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] A few questions


From: Michael Rice
Subject: [avr-libc-dev] A few questions
Date: Sat, 20 Apr 2013 12:48:34 -0400

During a discussion about setting the system time from NTP, a couple of things came up which make me want to make some changes.

================================

It seems more 'natural' to alter set_system_time() to...

        void set_system_time(time_t);

If setting from a calendar type RTC, you would pass the result of mktime() or mk_gmtime()...

        set_system_time(mk_gmtime(struct tm * rtc_values));

If setting from NTP...

        set_system_time(ntp_timestamp - NTP_OFFSET);

If setting from a binary type RTC...

        set_system_time(binary_timestamp);


If there are no objections, I will change set_system_time( struct tm *) into set_system_time(time_t)

=================================

The second thing, it could be beneficial if an application could 'over ride' the time() function (along with its companions set_system_time() and system_tick() ).

I can't think of any situation where it would do harm (it would be the applications responsibility to ensure atomicity, the offset from epoch, & etc ).

If there are no objections, the above mentioned functions will be declared with __attribute__((weak))

=================================

Lastly, there is the function month_length(). Currently it expects two parameters, the year and the 1 based month.

It could also be implemented to use the zero based month as derived from struct tm, or to use struct tm as its sole parameter.

There are good arguments for each of these.

Personally, I feel that if is best left as is, and that second best is ...
        uint8_t month_length( struct tm *);

I would like to hear from you about your opinion, what works best for you?

=================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]