How we solved daylight saving issue?

|  Posted: July 10, 2018  |  Categories: BizTalk360

DST in General

It is a universal practice around the world to observe daylight saving time(DST). We all moved our clocks one hour forward this last March. We woke up an hour sooner, had some additional espresso and tried to adjust to the jet-lag. Every spring we set the clocks forward and winter we turn the clock back. Most nations do not participate in DST and even within the USA, not all the states are participating in DST.

Real business scenario

In the software business, it is fundamental part to deal with business situations cautiously during the DST time. For instance, a company has rules created in an order taking system, that the order depends on the time of the order – if the clock changes, the rules might not be as clear. Like this, there are infinite scenarios we can consider.
In the integration business arena, a flow of the business information may happen from one end of the world to another. For this kind of situations, the business decision logic may work based on the time. Likewise, in BizTalk Server, administrators dependably should watch out for the deployed applications, its artifacts states and flow of the information. In case of anything turns out badly, there may be a huge effect on the mission-critical business (Eg: Banking, Insurance, Healthcare, Logistics etc.,). To stay away from these issues, BizTalk360 is used as an integral tool in 500+ business in 30+ nations.

Advanced Monitoring in BizTalk360

In BizTalk360, we have powerful monitoring capabilities to monitor the business information using the query builder functionality, which is looking for the information about suspended service instances, running service instances, tracked Service instances and tracked message events. Similarly, you can query BAM views, perform activity searches, filter out ESB exceptions, query the event logs and monitor Azure Logic apps.

Daylight Saving: Data Monitoring Dashboard

While monitoring this data, BizTalk360 will send notifications to many notification media. These media contain Email, SMS, inbuilt notification channels like Slack, ServiceNow, and Webhook. Customers can also create their own notification channels to receive the alerts from BizTalk360. To know more about our advanced data monitoring capability click here “https://assist.biztalk360.com/support/solutions/folders/1000221446”.

Problem Statement

We wanted to share our experience in solving a daylight-saving issue in our application for a specific scenario, where the email alerts are sent from the application properly during the normal days, whereas false alerts will be sent once during the daylight-saving time. We started investigating the scenario in deep to nail down the problem.

Forward Scenario

Consider below EST (Eastern Time Zone, UTC-5:00) DST change as an example.

Daylight Saving: Forward example

Set the system time zone settings as (UTC-08:00) Pacific Time (US & Canada) in BizTalk360.
Sunday, 11 March 2018, 02:00:00 clocks were turned forward 1 hour, to 03:00:00.
Let’s consider a scenario where Message Box data monitor is configured to monitor the suspended service instances for a purchase order application on an hourly basis. There is a column to show “Next Run At“ time which populates the next expected cycle for the data monitor. For an hourly based scenario, it will populate data consistently to notify the next run cycle. At the time of DST, in the 1:00 am cycle, next run time should be calculated as 3:00 am. Instead of this, Next run cycle is computed as 2:00 am. The BizTalk360 monitoring service will pick this time and try to convert the invalid time for further processing. Due to the invalid time, an exception appears in the email for only that monitoring cycle.


Daylight Saving: Email notification

Backward scenario

Sunday, 4 November 2018, 02:00:00 clocks are turned backward 1 hour to 01:00:00.
In the Fallback scenario, the issue won’t appear since the clock will be turned backward 1 hour and the monitoring service will come to look for the Next run time and wait until that time for further processing.

Code Snippet

As the problem stated above, DST adjustment has not been handled in the inbuilt .Net libraries. BizTalk360 properly calculates DST from V8.8 version onwards. In the below code snippet, in the highlighted text you can find the logic.

TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(regionalSetting.timezone.timezoneId);
if (timeZoneInfo.SupportsDaylightSavingTime)
{
    DateTime dateTime = nextRunDateTime;

    if (timeZoneInfo.IsAmbiguousTime(dateTime))
    {}

    if (timeZoneInfo.IsInvalidTime(dateTime))
    {
        DateTime adjustedDateTime = Helper.AdjustDateTimeForDSTChange
       (dateTime, regionalSetting);
    }
}

public static bool IsValidDateTime(DateTime dateTime, SystemRegionalSetting regionalSetting)
{
    TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById
    (regionalSetting.timezone.timezoneId);

    return timeZoneInfo.IsInvalidTime(dateTime) ? false : true;
}

public static DateTime AdjustDateTimeForDSTChange(DateTime dateTime, SystemRegionalSetting regionalSetting)
{
    TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById
    (regionalSetting.timezone.timezoneId);

    return dateTime.Add(timeZoneInfo.GetUtcOffset(dateTime.AddDays(1)) - timeZoneInfo.BaseUtcOffset);
}

Testing

Time conversion is much more complicated than you imagine, because different countries/locales switch to daylight saving time at different dates, it is not just one sweep change. Hence, we have thoughtfully derived the scenarios for testing to cover all the combinations.

Following are the test scenarios which we need to take care of during the DST testing:
1. UTC (Coordinated Universal Time)
2. GMT time zones which observers DST during summer time (Eg: British Summer Time)
3. UTC –(Minus) time zones which observe DST (Eg: Pacific Time US & Canada)
4. UTC –(Minus) time zones which don’t observe DST (Eg: Arizona)
5. UTC + (Plus) time zones which observe DST (CEST)
6. UTC +(Plus) time zones which don’t observe DST (IST)

Conclusion

We took a just more efficient way to solve the DST issue in our recent version 8.8. Happy migrating and try BizTalk360!!! Get started with the free 30 days trial. For any queries/feedback please write to us support@biztalk360.com.

Author: Mekala Ramesh

Test Lead at BizTalk360 - Software Testing Engineer having diverse exposure in various features and application testing with a comprehensive understanding of all aspects of SDLC. Strong knowledge to establish the testing process from the scratch. Love to test the software product to deliver it with good quality. Strongly believes on "Testing goes beyond just executing the test protocol".

Back to Top