Solved

Setting Daylight Savings Flag

Posted on 2002-03-13
5
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

688 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