By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,725 Members | 1,040 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,725 IT Pros & Developers. It's quick & easy.

daylight saving time

P: n/a
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
Nov 16 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
bernhard Hoyler wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 16 '07 #2

P: n/a
Victor Bazarov wrote:
bernhard Hoyler wrote:
>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.
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.
Nov 16 '07 #3

P: n/a
Juha Nieminen wrote:
Victor Bazarov wrote:
>bernhard Hoyler wrote:
>>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.

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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 16 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.