Hi, Readers.
Today I would like to share another mini tip about Business Central, how to check if the time zone supports daylight saving time (DST) via AL.
Daylight saving time (DST), also referred to as daylight savings time, daylight time (United States and Canada), or summer time (United Kingdom, European Union, and others), is the practice of advancing clocks to make better use of the longer daylight available during summer so that darkness falls at a later clock time. The standard implementation of DST is to set clocks forward by one hour in spring or late winter, and to set clocks back by one hour to standard time in the autumn. More details: Daylight saving time
In Business Central: About dates in Business Central
- Every Business Central user has a timezone specified on the page User Settings.
- When a user signs in to Business Central for the first time, this timezone is set using settings from the browser.
- Business Central stores all
DateTimefields as UTC and in the UI layer, we convert these fields to the timezone, specified by the user on the User Settings page.


However, the standard Time Zone table does not include daylight saving time (DST). Is there a way to display it?
Time Zone (2000000164):

Yes, we can use the following standard method.
codeunit 8720 “Time Zone” -> procedure TimeZoneSupportsDaylightSavingTime: Checks whether the indicated time zone supports daylight saving time.

TimeZoneId:

Let’s look at a simple example.

Very simple.

Great. Give it a try!!!😁
Test code:
pageextension 50128 TimeZonesLookupExt extends "Time Zones Lookup"
{
layout
{
addafter("Display Name")
{
field(IsSupportDTS; IsSupportDTS)
{
ApplicationArea = All;
Caption = 'Is Support DTS';
}
}
}
var
IsSupportDTS: Boolean;
trigger OnAfterGetRecord()
var
TimeZone: Codeunit "Time Zone";
begin
IsSupportDTS := false;
if TimeZone.TimeZoneSupportsDaylightSavingTime(Rec.ID) then
IsSupportDTS := true;
end;
}PS:
1. How to quickly get Coordinated Universal Time (UTC Time)
2. How to get timezone offset in AL
3. How to easily convert DateTime between UTC and local time (UTC Time Zone Converter)
END
Hope this will help.
Thanks for reading.
ZHU



コメント