Affected package: WmPublic
version 10.5.0.0.84
.
calculateDateDifference service and Daylight Saving Time (DST)
Recently we had some issues in production. When I looked closer, the service pub.date:calculateDateDifference
failed with the error could not be converted to a date.
That happened early morning on March 26. And yes, on March 26 at 2 AM, the time was shifted to 3 AM in timezones that use DST.
Our IS servers run in Central European Timezone (CET).
The service does not have a timezone
input parameter, so it falls back and uses the server’s timezone.
The service works as expected for any dates (with time part) outside DST changes.
For example, for input parameters:
startDate
: 2023-03-23 02:00:00
endDate
: 2023-03-23 03:00:00
startDatePattern
: yyyy-MM-dd HH:mm:ss
endDatePattern
: yyyy-MM-dd HH:mm:ss
You get the correct results.
Now try to get a date difference for any date between 2023-03-26 02:00:00
and 2023-03-26 02:59:59
, and you will get the error.
For example:
startDate
: 2023-03-26 02:00:00
endDate
: 2023-03-26 03:00:00
startDatePattern
: yyyy-MM-dd HH:mm:ss
endDatePattern
: yyyy-MM-dd HH:mm:ss
The service will produce could not be converted to a date error.
Well, technically, this is correct. There is no such date 2023-03-26 02:00:00 in the CET timezone, but such a date exists in the UTC timezone.
You might run into trouble using this service when calculating the difference, and one of the input dates is in UTC (our case), as UTC does not use DST.
The service should have a timezone
input parameter!
Until then, you will be better off using a java service instead.
The service is a ticking time bomb that can go off twice a year