473,379 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

daylight saving time

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
3 3946
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Amitabh Deepak | last post by:
Is there any way to check whether daylight saving is enabled on a linux machine?
1
by: Drew | last post by:
Is there a way to check if it is daylight savings or not via c#? I have heard you can use System.Globalization? Thanks - Drew
7
by: Brett Edman | last post by:
I created a UTC clock using this: UTCTime = MyTime.ToUniversalTime() Now that we've turned the clocks ahead 1 hour for daylight savings time, the clock is reporting the wrong UTC time. It is...
6
by: Robm | last post by:
Since googling this issue only brings up the April fool's problem, which was solved years ago, I hope that somebody can help me with this. I have a large vc++/mfc application which needs to know...
0
by: Chirag Shukla | last post by:
Colleagues, I wanted to share a function to find if a date is in Daylight Saving Time or not. I was able to make this function faster than reading MSDN to find functions that .NET provides. I...
1
by: maflatoun | last post by:
Hi everyone, I have 3 different time zones that I'm working with. Basically converting from UTC to those 3 time zones. Eastern Daylight Time (GMT -04:00, New York) Central Daylight Time (GMT...
1
by: maflatoun | last post by:
Hi everyone, I have 3 different time zones that I'm working with. Basically converting from UTC to those 3 time zones. Eastern Daylight Time (GMT -04:00, New York) Central Daylight Time (GMT...
1
by: luke_airig | last post by:
I'm not sure if this is the right group for this posting. If not, please accept my apologies. I have been tasked with identifying and correcting application code that will be affected by the...
27
by: RobG | last post by:
I was investigating a function to determine whether daylight saving was being observed on a particular date (given the platform's regional settings) and came across a suggestion at merlyn.com to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.