?
Solved

Setting Daylight Savings Flag

Posted on 2002-03-13
5
Medium Priority
?
325 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 150 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.
Suggested Courses

755 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