Scalabium Software

SMExport/SMImport suites
Knowledge for your independence'.
Home Delphi and C++Builder tips


#134: How read the daylight saving time?

Sometimes from code you want to find out if MS Windows is operating in saylight saving time. For example, I used this code in own GroupMail because in message header you must include a timestamp.

The code below allow to solve this task:

uses Windows;

const
  TIME_ZONE_ID_UNKNOWN  = 0;
  TIME_ZONE_ID_STANDARD = 1;
  TIME_ZONE_ID_DAYLIGHT = 2;

var
  tz : TTimeZoneInformation;
begin
  case GetTimeZoneInformation(tz) of
    TIME_ZONE_ID_STANDARD: ShowMessage(tz.StandardName);
    TIME_ZONE_ID_DAYLIGHT: ShowMessage(tz.DaylightName);
  else
    ShowMessage('Unknown state');
  end;
end;

Also I want to say that similar code you can use for BIAS reading (offset to UTC/GMT in minutes of local time zone):

function GetTimeZoneBias: Integer;
var
  tz: TTimeZoneInformation;
begin
  case GetTimeZoneInformation(tz) of
    TIME_ZONE_ID_STANDARD: Result := -(tz.StandardBias + tz.Bias) div (24*60);
    TIME_ZONE_ID_DAYLIGHT: Result := -(tz.DaylightBias + tz.Bias) div (24*60);
  else
    Result := 0;
  end;
end;

If the result is 0 then time is a GMT. Else you'll receive a difference as positive or negative value.


Published: December 12, 2001

See also
 
Viewer for MS Outlook Messages
Excel Web-stream
ExcelFile Viewer
DBISAM Password Recovery
Word Web-stream
DBExport tools
SMMsg suite
Excel Reader (dll)
Paradox Viewer
Paradox ActiveX
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising