473,769 Members | 3,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3978
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
5540
by: Amitabh Deepak | last post by:
Is there any way to check whether daylight saving is enabled on a linux machine?
1
30150
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
4093
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 reporting UTC + 1 hour. Is this a bug or is there a way I can querey for daylight time and make the adjustment in my application? Thanks.
6
8843
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 when DST is in effect. This has been working fine for years, but I am worried about the upcoming change in 2007 in the US, which will be followed by a number of Canadian provices (where my application is used). The function that I use is very...
0
1511
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 didnt know if .NET was equipped with the new changes President Bush made with respect to Daylight Saving Time increase starting 2007. I could have found out by trying ..NET functions, only if I wasnt a lousy syntax scavanger. Here goes:
1
3224
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 -05:00, Chicago) Pacific Daylight Time (GMT -07:00, San Francisco) Using C# I know how to detect if Daylight saving time is applied or not
1
4529
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 -05:00, Chicago) Pacific Daylight Time (GMT -07:00, San Francisco) Using C# I know how to detect if Daylight saving time is applied or not
1
2001
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 new daylight saving time change that goes into effect 2007/03/11. This is a .Net application with thousands of lines of c#, javascript and html. As I currently understand it, relevant patches will be supplied and applied to the affected web...
27
6891
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 test the time zone offset on a variety of dates to see if it changes. Based on that, I developed the following checkDST() function which, as far as I can tell, should be sufficient. It checks either the date passed to it or the current date with...
0
10214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10048
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3963
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.