198
Views
4
Comments
Handling Time Zones and Daylight Saving Time in the Server Side (Reactive app)
Application Type
Reactive

Hi everyone,

I am working on a reactive application in OutSystems, specifically a booking system where users need to sign up for a slot before 10:30 AM (my time zone, Italy) on the same day. The challenge I'm facing is how to consistently check user’s time against my cut-off time.

Details:

  • As we all know, the OutSystems server time is in UTC.
  • My time zone is currently UTC+2 (during daylight saving time) and UTC+1 in winter, changing twice a year.
  • I want to ensure users can only book up to 10:30 AM Italy time without having to manually adjust settings for daylight saving time twice a year.

Current Implementation:

  • Checking the time on the client side using user device time, but this may not be reliable.

Questions:

  1. What is the best way to handle this time zone conversion reliably in OutSystems?
  2. Are there any built-in functions or recommended practices for dealing with daylight saving time automatically?
  3. How can I ensure the system consistently checks if the current time is before 10:30 AM Italy time without manual adjustments?

Ideally, I would like to convert the server time to Italy’s time zone time in a server action (it should automatically handle daylight saving), then compare it against 10:30 AM and make the necessary adjustments based on that.

I would appreciate any guidance, sample code, or references to relevant documentation that could help solve this issue efficiently.

Thank you in advance for your help!

2021-11-12 04-59-31
Manikandan Sambasivam

@Andrea Caselli 

Approach

  1. Use Server Time in UTC: Since the OutSystems server time is in UTC, you can work with UTC time on the server-side.
  2. Convert UTC to Italy Time: Use a combination of built-in functions and custom logic to convert UTC time to Italy time, accounting for DST automatically.
  3. Compare Against Cut-Off Time: Once you have the current time in Italy, you can compare it against the 10:30 AM cut-off.

Steps to Implement

1. Get the Current Server Time in UTC

Use the CurrDateTime() function to get the current server time in UTC.

2. Convert UTC to Italy Time

You can use a custom function to handle the conversion, considering DST changes. This involves using standard library functions to determine if DST is currently in effect in Italy and adjusting the time accordingly.

3. Compare Against 10:30 AM Italy Time

After converting the time, compare it to 10:30 AM Italy time.

UserImage.jpg
Andrea Caselli

Hi @Manikandan Sambasivam ,

Thank you for your detailed response.

I would consider this as my plan B and expected that there would be an easier/already made solution. The custom function will have to calculate the current local time based on the date and then compare it.

If anyone knows of a more straightforward or built-in way to handle this in OutSystems, especially regarding automatic DST adjustments, please let me know. Any additional insights or examples would be greatly appreciated.

Thanks again!

Andrea

2024-12-02 12-15-17
Aravind EONE

Hi Andrea Caselli,

We had similar requirement to have DST time on server side for validations.

So I have developed a .NET extension to pass the timezone code and date time as input parameter to this .NET extension,

then I have added logic to fetch correct DST time for the UTC.

Hence UTC to Destination Timezone and destination to UTC conversions are handled.

I will add more details here, Since this is an OLD post.

For client side we have used javascript to do the same.


 https://www.outsystems.com/forums/discussion/102380/how-we-can-handle-time-zones-and-daylight-saving-time/ 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.