EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Daylight savings date identification over the net

Started by Dimiter_Popoff March 30, 2014
About every year when it comes to it I search some reasonable
way to implement it and shortly after I give it upand go
empty handed.
Does anyone know how do MS and Android devices do it?
Where do they look the date up?
Eventually I suppose I'll do some sort of service for
DPS devices myself but it would be
nice if there were something similar to NTP to use.

Dimiter

------------------------------------------------------
Dimiter Popoff, TGI             http://www.tgi-sci.com
------------------------------------------------------
http://www.flickr.com/photos/didi_tgi/sets/72157600228621276/
On 2014-03-30, Dimiter_Popoff <dp@tgi-sci.com> wrote:
> About every year when it comes to it I search some reasonable > way to implement it and shortly after I give it upand go > empty handed. > Does anyone know how do MS and Android devices do it? > Where do they look the date up? > Eventually I suppose I'll do some sort of service for > DPS devices myself but it would be > nice if there were something similar to NTP to use. >
What's wrong with just using the timezone database ? See http://www.iana.org/time-zones Some background information is at: http://en.wikipedia.org/wiki/Tz_database Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world
On Sun, 30 Mar 2014 12:22:10 +0300, Dimiter_Popoff <dp@tgi-sci.com>
wrote:

>About every year when it comes to it I search some reasonable >way to implement it and shortly after I give it upand go >empty handed.
There is no such thing !! Last night Crimea went from UTC+2 (East Europe Standard Time) to Moscow time (UTC+4 all year around) at UTC 20:00 yesterday. The rest of Europe did the transition at 01:00 UTC from standard to daylight saving time.
>Does anyone know how do MS and Android devices do it? >Where do they look the date up?
In Microsoft environment, the TZ environmental variable is quite expressive, but who is going to update for your region ? Mr. Putin ?
>Eventually I suppose I'll do some sort of service for >DPS devices myself but it would be >nice if there were something similar to NTP to use.
NTP only carries the leap second warning signal. The daylight saving time is far too political to be handled technically :-(
On 30/03/14 10:47, Simon Clubley wrote:
> On 2014-03-30, Dimiter_Popoff <dp@tgi-sci.com> wrote: >> About every year when it comes to it I search some reasonable >> way to implement it and shortly after I give it upand go >> empty handed. >> Does anyone know how do MS and Android devices do it? >> Where do they look the date up? >> Eventually I suppose I'll do some sort of service for >> DPS devices myself but it would be >> nice if there were something similar to NTP to use. >> > > What's wrong with just using the timezone database ?
Fine, provided you know location, can interpret the database correctly(!) and can update the embedded equipment when the rules change. Anything to do with calendars is 10% more difficult than you thought. Recursively. Favourite questions for youngsters: - how many days in a year - how many months in a year - how many hours in a day - how many seconds in a minute Clueless youngsters /usually/ get one of those right; very few youngsters get them all right.
Tom Gardner <spamjunk@blueyonder.co.uk> wrote:
> Anything to do with calendars is 10% more difficult than > you thought. Recursively. > > Favourite questions for youngsters: > - how many days in a year > - how many months in a year > - how many hours in a day > - how many seconds in a minute > Clueless youngsters /usually/ get one of those right; > very few youngsters get them all right.
I'm not exactly a youngster, but given the superficial simplicity of your question, I guess I am missing something important. Can you expand a bit on the topic or point to resources that explain all the nitty gritty bits? -- Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org
Nils M Holm <news2009@t3x.org> writes:
>> Favourite questions for youngsters: >> - how many days in a year >> - how many months in a year >> - how many hours in a day >> - how many seconds in a minute >> Clueless youngsters /usually/ get one of those right; >> very few youngsters get them all right. > > I'm not exactly a youngster, but given the superficial > simplicity of your question, I guess I am missing something > important. Can you expand a bit on the topic or point to > resources that explain all the nitty gritty bits?
Astronomy buffs will probably get them right ;-). My guesses: Days in a year: http://en.wikipedia.org/wiki/Year#Calendar_year Simplified answer: about 365.2425 days. The ancient Romans approximated this as 365.25 days, handled with a 365-day calendar plus 1 leap day added every 4 years, the so-called Julian calendar. The discrepancy built up over the centuries til it was adjusted in the 18th century (depending on where you were), by skipping 11 days and changing the leap year algorithm slightly, giving the Gregorian calendar now in use. Try the Unix command "cal 9 1752" or see: http://en.wikipedia.org/wiki/Old_Style_1752 Months in a year: I think this is supposed to be the one everyone gets right, i.e. 12, but of course I'm suspicious. I've heard that the one thing that's really stayed constant is 7, the number of days in a week. Hours in a day: varies slightly, but the period of the earth's rotation (sidereal day) is about 23.9344699 hours (23h 56m 4.09 sec). The solar day is slightly longer (averages just a tiny bit over 24h) but its length varies with the season: http://en.wikipedia.org/wiki/Solar_time Seconds in a minute: 60 but sometimes there is a forward or backward leap second. http://en.wikipedia.org/wiki/Leap_second
On 30/03/14 13:15, Nils M Holm wrote:
> Tom Gardner <spamjunk@blueyonder.co.uk> wrote: >> Anything to do with calendars is 10% more difficult than >> you thought. Recursively. >> >> Favourite questions for youngsters: >> - how many days in a year >> - how many months in a year >> - how many hours in a day >> - how many seconds in a minute >> Clueless youngsters /usually/ get one of those right; >> very few youngsters get them all right. > > I'm not exactly a youngster, but given the superficial > simplicity of your question, I guess I am missing something > important. Can you expand a bit on the topic or point to > resources that explain all the nitty gritty bits? >
I am not a youngster either, and I can have a shot here off the top of my head. My guess is that I'll have missed something. The number of days in a year depends on the leap year. The rules are, I think: if (y % 4) { return 365; } else if (y % 100) { return 366; } else if (y % 400) { return 365; } else if (y % 2000) { return 366; } else { return 365; } There are 12 months in a year (I'm assuming the modern western calendar here, of course). There are 24 hours in a day. There are 60 minutes in an hour. There are 60 seconds in most minutes. But every now and again, there is a leap second, meaning that there are some minutes with 61 seconds. There is no fixed pattern in this - it is based on astronomical observations (whose fine details are chaotic), and decided on by some committee somewhere.
On Sun, 30 Mar 2014 11:11:20 +0100, Tom Gardner
<spamjunk@blueyonder.co.uk> wrote:

>On 30/03/14 10:47, Simon Clubley wrote: >> On 2014-03-30, Dimiter_Popoff <dp@tgi-sci.com> wrote: >>> About every year when it comes to it I search some reasonable >>> way to implement it and shortly after I give it upand go >>> empty handed. >>> Does anyone know how do MS and Android devices do it? >>> Where do they look the date up? >>> Eventually I suppose I'll do some sort of service for >>> DPS devices myself but it would be >>> nice if there were something similar to NTP to use. >>> >> >> What's wrong with just using the timezone database ? > >Fine, provided you know location, can interpret the >database correctly(!) and can update the embedded >equipment when the rules change. > >Anything to do with calendars is 10% more difficult than >you thought. Recursively. > >Favourite questions for youngsters: > - how many days in a year
354, 365, 366, etc. completely culture dependant.
> - how many months in a year
12 or 13 depending on culture.
> - how many hours in a day
usually 24
> - how many seconds in a minute
59, 60 or 61 depending on the leap second issue.
>Clueless youngsters /usually/ get one of those right; >very few youngsters get them all right.
You seem to be quite optimistic.
On Sun, 30 Mar 2014 05:10:34 -0700, Paul Rubin
<no.email@nospam.invalid> wrote:

>Nils M Holm <news2009@t3x.org> writes: >>> Favourite questions for youngsters: >>> - how many days in a year >>> - how many months in a year >>> - how many hours in a day >>> - how many seconds in a minute >>> Clueless youngsters /usually/ get one of those right; >>> very few youngsters get them all right. >> >> I'm not exactly a youngster, but given the superficial >> simplicity of your question, I guess I am missing something >> important. Can you expand a bit on the topic or point to >> resources that explain all the nitty gritty bits? > >Astronomy buffs will probably get them right ;-). My guesses: > >Days in a year: http://en.wikipedia.org/wiki/Year#Calendar_year >Simplified answer: about 365.2425 days.
Shouldn't the correct answer be "365 in most years and 366 in leap years," non-integral days being somewhat awkward to implement. Otherwise, we'd tack on not quite 6 hours to the end of the day on 31 December. Which, actually, seems like a rather good idea except for the inconvenience of moving "midnight" around every year. ;-)
On 30/03/14 13:53, upsidedown@downunder.com wrote:
> On Sun, 30 Mar 2014 11:11:20 +0100, Tom Gardner > <spamjunk@blueyonder.co.uk> wrote: > >> On 30/03/14 10:47, Simon Clubley wrote: >>> On 2014-03-30, Dimiter_Popoff <dp@tgi-sci.com> wrote: >>>> About every year when it comes to it I search some reasonable >>>> way to implement it and shortly after I give it upand go >>>> empty handed. >>>> Does anyone know how do MS and Android devices do it? >>>> Where do they look the date up? >>>> Eventually I suppose I'll do some sort of service for >>>> DPS devices myself but it would be >>>> nice if there were something similar to NTP to use. >>>> >>> >>> What's wrong with just using the timezone database ? >> >> Fine, provided you know location, can interpret the >> database correctly(!) and can update the embedded >> equipment when the rules change. >> >> Anything to do with calendars is 10% more difficult than >> you thought. Recursively. >> >> Favourite questions for youngsters: >> - how many days in a year > > 354, 365, 366, etc. completely culture dependant.
That's a good example of the 10% rule for me. I've never come across the 354; was it due to the change from Julian to Gregorian calendar?
>> - how many months in a year > > 12 or 13 depending on culture.
Precisely. Most people fail to get that one right.
>> - how many hours in a day > > usually 24
23 today in the UK :)
>> - how many seconds in a minute > > 59, 60 or 61 depending on the leap second issue.
I didn't realise 59 was even a possibility, but it hasn't happened yet. I understands why the earth's rotation has slowed from a day being 6 hours, but I don't see how it could speed up!
>> Clueless youngsters /usually/ get one of those right; >> very few youngsters get them all right. > > You seem to be quite optimistic.
They usually get 366 days in a year, during my pause after they've said 365.

Memfault Beyond the Launch