Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1002157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:47:24+00:00 2026-05-16T07:47:24+00:00

I need somehow to determine whether some TDateTime value is within the Daylight Saving

  • 0

I need somehow to determine whether some TDateTime value is within the Daylight Saving Time range for my timezone or not (in C# the same thing does the DateTime.IsDaylightSavingTime() method).

I know in Delphi there’s no similar function, because Delphi TDateTime contains no information about timezone, but I suppose there’s some way how to do this using Win32 API.

I’ve looked at Win32 API GetTimeZoneInformation and GetTimeZoneInformationForYear functions, but I don’t quite understand how to use them, so I’d like to ask you for help. Thanks in advance for any tips.

Edit:

Example:

In my timezone (Central European) Daylight Saving Time started this year on
28th March at 2 am and ends on 31st October 2010 at 3 am.

I need a function with header:

function IsDaylightSavingTime(input: TDateTime): boolean;

that will return true if the input date is between 28th March 2010 2:00 and 31st October 2010 3:00 and false if not.

(The example is just for year 2010, but I’d need it to work for all years.)

Once again, I know that information saved in TDateTime alone is not enough, but I think that with some Win32 API function I should be able to get e.g. information about current timezone from Windows settings.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:47:25+00:00Added an answer on May 16, 2026 at 7:47 am

    It is not as easy as it sounds, because:

    1) The switch-over date between DST and standard time is not the same for all countries

    2) The switch-over date between DST and standard time is not the same algorithm for the same country for all years (for example in Central Europe it was previously first Sunday in April, IIRC, now it is last Sunday in March). The USA changed from first Sunday in April to the second Sunday in March from 2007 and on.

    So – a simple date is not enough, you’ll also need a geographical location.

    But, if you can live with the fact, that you limit yourself to the switch-over dates that can be calculated from the CURRENT algorithm for the CURRENT year for the CURRENT locale (country) and that this may be wrong for dates both in the future and in the past, then you can use the information in TIME_ZONE_INFORMATION to calculate the switch-over dates:

    USES Windows,SysUtils,DateUtils;
    
    FUNCTION GetDaylightSavingsSwitchOverDates(Year : Cardinal ; VAR Start,Stop : TDateTime) : BOOLEAN;
    
      VAR
        TZ : TTimeZoneInformation;
    
      FUNCTION DecodeSwitchOverDate(Year : Cardinal ; CONST Time : TSystemTime) : TDateTime;
        VAR
          I : Cardinal;
    
        BEGIN
          Result:=EncodeDateTime(Year,Time.wMonth,1,Time.wHour,Time.wMinute,Time.wSecond,0);
          IF Time.wDay=5 THEN BEGIN
            Result:=DateOf(EndOfTheMonth(Result))+TimeOf(Result);
            WHILE PRED(DayOfWeek(Result))<>Time.wDayOfWeek DO
              Result:=IncDay(Result,-1)
            END
          ELSE BEGIN
            WHILE PRED(DayOfWeek(Result))<>Time.wDayOfWeek DO Result:=IncDay(Result);
            FOR I:=1 TO PRED(Time.wDay) DO Result:=IncWeek(Result)
          END
        END;
    
      BEGIN
        IF GetTimeZoneInformation(TZ)=TIME_ZONE_ID_UNKNOWN THEN
          Result:=FALSE
        ELSE BEGIN
          Start:=DecodeSwitchOverDate(Year,TZ.DaylightDate);
          Stop:=DecodeSwitchOverDate(Year,TZ.StandardDate);
          Result:=TRUE
        END
      END;
    
    FUNCTION StartOfDST(Year : Cardinal) : TDateTime;
      VAR
        Stop : TDateTime;
    
      BEGIN
        IF NOT GetDaylightSavingsSwitchOverDates(Year,Result,Stop) THEN Result:=0
      END;
    
    FUNCTION EndOfDST(Year : Cardinal) : TDateTime;
      VAR
        Start : TDateTime;
    
      BEGIN
        IF NOT GetDaylightSavingsSwitchOverDates(Year,Start,Result) THEN Result:=0
      END;
    

    Looping through the years 2000 to 2020 on my PC (Central Europe Time Zone), I get the following dates:

    DST in 2000: Sun 26 Mar 2000 02:00:00 through Sun 29 Oct 2000 03:00:00
    DST in 2001: Sun 25 Mar 2001 02:00:00 through Sun 28 Oct 2001 03:00:00
    DST in 2002: Sun 31 Mar 2002 02:00:00 through Sun 27 Oct 2002 03:00:00
    DST in 2003: Sun 30 Mar 2003 02:00:00 through Sun 26 Oct 2003 03:00:00
    DST in 2004: Sun 28 Mar 2004 02:00:00 through Sun 31 Oct 2004 03:00:00
    DST in 2005: Sun 27 Mar 2005 02:00:00 through Sun 30 Oct 2005 03:00:00
    DST in 2006: Sun 26 Mar 2006 02:00:00 through Sun 29 Oct 2006 03:00:00
    DST in 2007: Sun 25 Mar 2007 02:00:00 through Sun 28 Oct 2007 03:00:00
    DST in 2008: Sun 30 Mar 2008 02:00:00 through Sun 26 Oct 2008 03:00:00
    DST in 2009: Sun 29 Mar 2009 02:00:00 through Sun 25 Oct 2009 03:00:00
    DST in 2010: Sun 28 Mar 2010 02:00:00 through Sun 31 Oct 2010 03:00:00
    DST in 2011: Sun 27 Mar 2011 02:00:00 through Sun 30 Oct 2011 03:00:00
    DST in 2012: Sun 25 Mar 2012 02:00:00 through Sun 28 Oct 2012 03:00:00
    DST in 2013: Sun 31 Mar 2013 02:00:00 through Sun 27 Oct 2013 03:00:00
    DST in 2014: Sun 30 Mar 2014 02:00:00 through Sun 26 Oct 2014 03:00:00
    DST in 2015: Sun 29 Mar 2015 02:00:00 through Sun 25 Oct 2015 03:00:00
    DST in 2016: Sun 27 Mar 2016 02:00:00 through Sun 30 Oct 2016 03:00:00
    DST in 2017: Sun 26 Mar 2017 02:00:00 through Sun 29 Oct 2017 03:00:00
    DST in 2018: Sun 25 Mar 2018 02:00:00 through Sun 28 Oct 2018 03:00:00
    DST in 2019: Sun 31 Mar 2019 02:00:00 through Sun 27 Oct 2019 03:00:00
    DST in 2020: Sun 29 Mar 2020 02:00:00 through Sun 25 Oct 2020 03:00:00
    

    but at least some of these years are incorrect due to the algorithm having changed from my locale in the years listed.

    Your function would then be:

    FUNCTION IsDaylightSavingTime(Input : TDateTime) : BOOLEAN;
      VAR
        Start,Stop : TDateTime;
    
      BEGIN
        Result:=GetDaylightSavingsSwitchOverDates(YearOf(Input),Start,Stop) AND (Input>=Start) AND (Input<Stop)
      END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For an iPhone app that submits images to a server I need somehow to
I need to generate multiple random values under SQL Server 2005 and somehow this
On the client machine I need to be able to somehow detect which sites
need ask you about some help. I have web app running in Net 2.0.
Is there a way (preferrably using JavaScript) to determine whether a URL is to
Need a function that takes a character as a parameter and returns true if
Need a way to allow sorting except for last item with in a list.
Need to an expression that returns only things with an I followed by either
Need to locate the following pattern: The letter I followed by a space then
Need a function like: function isGoogleURL(url) { ... } that returns true iff URL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.