Solved

Setting Daylight Savings Flag

Posted on 2002-03-13
5
281 Views
Last Modified: 2008-02-01
I have some code to set the time & timezone on my machine.  To do this I use the SetLocalTime and SetTimezoneInformation methods.  What I can't seem to do is find a way to set the daylight savings flag on or off.  Can someone please let me know how to do this?  I'm guessing its just a matter of setting the correct information in the SYSTEMTIME struct I use when calling SetTimezoneInformation?
0
Comment
Question by:jpick
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
Nick75 earned 50 total points
ID: 6861324
#include <time.h>
#include <stdlib.h>
#include <stdio.h>

void main( void )
{
   if( _putenv( "TZ=EST5EDT" ) == -1 )
   {
      printf( "Unable to set TZ\n" );
      exit( 1 );
   }
   else
   {
      _tzset();
      printf( "_daylight = %d\n", _daylight );
      printf( "_timezone = %ld\n", _timezone );
      printf( "_tzname[0] = %s\n", _tzname[0] );
   }
   exit( 0 );
}
0
 

Author Comment

by:jpick
ID: 6862920
Thanks Nick75, I've seen that in the documentation(msdn).  The trouble is how do you know the 3 letter code for all the timezones, not just the ones in the US?  So if I live in Europe somewhere, how would I turn on/off daylight savings?
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7036228
Please update and finalize this old, open question. Please:

1) Award points ... if you need Moderator assistance to split points, comment here with details please or advise us in Community Support with a zero point question and this question link.
2) Ask us to delete it if it has no value to you or others
3) Ask for a refund so that we can move it to our PAQ at zero points if it did not help you but may help others.

EXPERT INPUT WITH CLOSING RECOMMENDATIONS IS APPRECIATED IF ASKER DOES NOT RESPOND.

Thanks,

** Mindphaser - Community Support Moderator **

P.S.  Click your Member Profile, choose View Question History to go through all your open and locked questions to update them.
0
 

Author Comment

by:jpick
ID: 7037441
Although this is not the answer I was looking for, I will give nick the points.
0
 
LVL 1

Expert Comment

by:Nick75
ID: 7037544
Have you played with the Bias member of TIME_ZONE_INFORMATION?

I'd assume "Coordinated Universal Time (UTC)" to mean GMT.  You may then choose to have an enumerated type or map<string,LONG> for various timezones around the world.  If you double click the clock on the Windows toolbar that'll get you started with a few offsets.  I won't guarantee that this is a full list - I'm sure I remember the timezone being off by 15 minutes somewhere - though I could be wrong - I'm sure they would have complained to MS... (but then, hasn't everybody :-) )
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now