trimToDays does not work with DST (Winter)

0
When applying the trimToDays function in summer the result is correct 17-06-2013 12:02 becomes 17-06-2013 00:00 But in the winter it does not 17-01-2013 12:02 becomes 17-01-2013 01:00 Same count for formatDateTime($var_dateTime,'HH') 17-06-2013 12:02 becomes 12 But in the winter it does not 17-01-2013 12:02 becomes 11 Why? When add the 2 in both on winter it works out fine, but when one of the date is not in the same DST it will go wrong. If the behavior above is correct..... how should I correct this in my code? Can I check if a dateTime is in DST? Thank you, Andries
asked
2 answers
3

Most likely your problem is that you did not set a timezone for the user you're doing this with. This means that the client passes an offset to the server. This works as long as operations involving time are in the current timezone but not when something like DST changes, which is in effect a timezone change.

The solution would be to set a timezone for this user and/or to set a default timezone in your project.

You can read more on this topic at https://world.mendix.com/display/refguide3/Date+and+Time+Handling+in+3.0

answered
0

In which timezones are the input and output dates you mention? I guess trimToDays trims to 00:00 in the user's timezone, but that could be 01:00 in UTC if the user's timezone has an offset of -1. When you want to trim a date to the begin of the day in UTC, you should use trimToDaysUTC. As for formatDateTime and formatDateTimeUTC.

answered