daylight saving time

B

bernhard Hoyler

Hi,

I would like to determine whether at a certain time point in time the
daylight savings time is in effect. This means such a logic should show
that today (16-Nov-2007) no daylight savings time (or European summertime)
is in effect, but at 1-Aug-2007 it is.

Thanks for your help

Bernhard Hoyler
 
V

Victor Bazarov

bernhard said:
I would like to determine whether at a certain time point in time the
daylight savings time is in effect. This means such a logic should
show that today (16-Nov-2007) no daylight savings time (or European
summertime) is in effect, but at 1-Aug-2007 it is.

The simplest way would be to have our own table of correct values and
compare against those ranges. You'd have to keep historical data since
the laws about daylight saving were introduced in different places at
different times. You also need to account for the place where the
program is running since some locales don't support daylight saving
times (like Arizona or parts of Indiana, IIRC). Also, the times at
which DST goes in effect are different in different countries.

OTOH you could of course rely on the member of the 'tm' struct, called
tm_isdst. Google for it, I am sure there are example of how to use it.

V
 
J

Juha Nieminen

Victor said:
The simplest way would be to have our own table of correct values and
compare against those ranges.

No, that's not the simplest way.

The simplest way is to use std::time() and then std::localtime().
The latter returns a struct tm, which contains the member variable
tm_isdst which tells the info he is looking for.

Unless my manpage is wrong, this should even be standard.

CONFORMING TO
SVr4, POSIX.1-2001, 4.3BSD, C89, C99.
 
V

Victor Bazarov

Juha said:
No, that's not the simplest way.

The simplest way is to use std::time() and then std::localtime().
The latter returns a struct tm, which contains the member variable
tm_isdst which tells the info he is looking for.

Unless my manpage is wrong, this should even be standard.

CONFORMING TO
SVr4, POSIX.1-2001, 4.3BSD, C89, C99.

Are you sure that those functions and the struct provide the correct
functionality for finding out, say, whether the WWI ended during DST
or not? What if I enter the DOB of the Pope, will I know if he was
born during European summertime?

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top