Timer Interrupt

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Tim

Re:Timer Interrupt

Post by Tim »

Summer/winter time is a huge can of worms. Basically: There's no formula which will predict when the changeover point is for all locations. The US and UK are easy. Elsewhere the rules change from time to time. Some countries don't change their clocks. Some countries (e.g. Israel) decide the changeover points on a year-by-year basis.

See here for why summer/winter time is so hard to get right, and what Win32 and .NET do about it (they handle it differently, by the way).
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:Timer Interrupt

Post by bubach »

i changed my clock to summer-time yesterday..
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
DennisCGc

Re:Timer Interrupt

Post by DennisCGc »

Me too ;D
Here the rules are:

- the last weekend of March, the clock must be set to summer time, on Sunday
- the last weekend of October, the clock must be set to winter time, on Sunday.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Timer Interrupt

Post by Candy »

DennisCGc wrote: Here the rules are:

- the last weekend of March, the clock must be set to summer time, on Sunday
- the last weekend of October, the clock must be set to winter time, on Sunday.
If you'd read Tim's post, you'd know it's not that easy. The point of it all is that the rules are NOT worldwide the same, NOT constant over time, and even HOW you apply the winter/summertime is not constant, even in one OS (well, that's probably a windows-only thing).

It's harder than that.

Microsoft comment for the people that are too lame to click on the link:
Another reason is that the laws regarding daylight savings time are in constant flux. For example, if the year in the example above was 1977 instead of 2000, the conversion would have been correct because the United States was running on year-round Daylight Savings Time due to the energy crisis. Of course, this information isn't encoded anywhere in the TIME_ZONE_INFORMATION structure. Similarly, during World War 2, the United States went on DST all year round. And between 1945 and 1966, the DST rules varied from region to region.

DST rules are in flux even today. The DST cutover dates in Israel are decided on a year-by-year basis by the Knesset. As a result, there is no deterministic formula for the day, and therefore no way to know it ahead of time.
DennisCGc

Re:Timer Interrupt

Post by DennisCGc »

Candy wrote:
DennisCGc wrote: Here the rules are:

- the last weekend of March, the clock must be set to summer time, on Sunday
- the last weekend of October, the clock must be set to winter time, on Sunday.
I MEAN, in the Netherlands, Here is referencing to HOLLAND! >:(
Therx

Re:Timer Interrupt

Post by Therx »

OT : why are the netherlands sometimes called holland?

Pete
DennisCGc

Re:Timer Interrupt

Post by DennisCGc »

Pete wrote: OT : why are the netherlands sometimes called holland?

Pete
Don't know, HOL means hollow, so, maybe it has a meaning ::)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Timer Interrupt

Post by Solar »

Dennis, I am surprised that you - referring to the Netherlands as "here" - don't know...

The formal name of the country is Netherlands, full stop.

There are several counties (or however you'd call them in English) that constitute the Netherlands. The most important of them happen to be North Holland and South Holland. Zeeland and Groningen are two more.

The overwhelming importance of Holland (and the comparative "complexity" of the word "Ne-ther-lands") led to "Holland" being used synonymously.

Happens easier than you'd think. Most US people think all of Germany has mountains, people wearing Lederhosen and eating lots of Sauerkraut. 8)
Every good solution is obvious once you've found it.
DennisCGc

Re:Timer Interrupt

Post by DennisCGc »

Uhm, do you know what the Netherlands means ?
And, unlike the United States, The Netherlands has provinces, and we're united, which means, every province has the same rules, and each state in the U.S. has other rules, except the basic rules.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Timer Interrupt

Post by Candy »

Solar wrote: There are several counties (or however you'd call them in English) that constitute the Netherlands. The most important of them happen to be North Holland and South Holland. Zeeland and Groningen are two more.
*feels the need for completion*

Their actual name should be "province", the dutch name is "provincie" (which is pronounced the same, but the ending ie is pronounced similar to an english y, and it gets the focus)

The full list is Zuid-Holland, Noord-Holland, Zeeland (these three comprise the east), Utrecht in the center, Drente, Groningen and Leeuwarden in the north, Limburg, Noord-Brabant and Gelderland in the south and Overijssel in the east. Since somebody called Leeghwater (which through translation becomes empty-water) emptied out some of the IJsselmeer of water, it now contains a province called Flevoland. That constitutes all 12 provinces :)

Enough of this, let's get back to topic (and that's not summertime or even time, but the timer interrupt).
ich_will

Re:Timer Interrupt

Post by ich_will »

Thats all very fine but like Candy says thats have nothing to do with my problem. How can I get the correct dates etc. from my secs variable? Or should I do something else?
DennisCGc

Re:Timer Interrupt

Post by DennisCGc »

Read the CMOS its registers.
Because the CMOS "keeps on running", you only have to read its date.
And, if your OS switchs from 23:59 to 0:00, then you should increase your day register.
If the day is over 31 (or 30 or 29, depends on what month it is), it should increase the month, if month is over 12, increase year.
If you don't know sure about the months(eg. how many days they have), then you should read the CMOS again (when switched a day).

HTH.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Timer Interrupt

Post by Candy »

ich_will wrote: Thats all very fine but like Candy says thats have nothing to do with my problem. How can I get the correct dates etc. from my secs variable? Or should I do something else?
*goes back to topic*

Your dates & everything are in BCD format. (direct quote from reply #1 and #2)

You convert them using dec= bcd-((bcd>>4)*6); (direct quote from reply #5)

Every N interrupts (where N is the frequency of your timer) you can increase the internal timer in your OS. Or, at your option, read out the CMOS time again. You can also use the timer interrupt for normal second / minute counting and sync with an NTP server every hour

What you do is completely your choice, however.
Post Reply