CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    9

    Daylight Savings Time

    Is there a way to tell if daylight savings time is active. I need to check for daylight savings time and my program needs to perform two different functions depending whether the time zone is currently in DST or not

    Thanks


  2. #2
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    11

    Re: Daylight Savings Time

    Hi,

    to check if daylight saving is in effect you do this:

    for the current time
    ====================
    setlocale( LC_ALL, "" ); // don't forget to set the locale
    if( CTime::GetCurrentTime( ).GetLocalTm( )->tm_isdst == 0 )
    {
    TRACE0( "daylight saving is not in effect\n" );
    }
    else
    {
    TRACE0( "daylight saving is in effect\n" );
    }

    for any time
    ============
    setlocale( LC_ALL, "" ); // don't forget to set the locale
    if( CTime( 1999, 4, 7, 8, 53, 0, -1 ).GetLocalTm( )->tm_isdst == 0 )
    {
    TRACE0( "daylight saving is not in effect\n" );
    }
    else
    {
    TRACE0( "daylight saving is in effect\n" );
    }

    HTH
    Holger


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured