Adam Cameron
Adam Cameron
setTimeZone("Asia/Karachi")
// control
dlsSwitchOver = createDateTime(2022,6,1,0,0,0)
writeOutput(dlsSwitchOver.dateTimeFormat("yyyy-mm-dd HH:nn:ss")) // Both CF and Lucee: 2022-06-01 00:00:00
writeOutput("<hr>")
// experiment
try {
dlsSwitchOver = createDateTime(2008,6,1,0,0,0)
writeOutput(dlsSwitchOver.dateTimeFormat("yyyy-mm-dd HH:nn:ss")) // Lucee: 2008-06-01 01:00:00
} catch (any e) {
writeOutput(e.message) // CF: Date value passed to date function createDateTime is unspecified or invalid.
}
Note the behavioural difference between CF2021 and Lucee there.
Lucee goes "yeah, OK, you say 2008-06-01 00:00:00
, but on that day the clocks go forward right then, so it's actually 2008-06-01 01:00:00
".
CF goes "yeah, OK, you say 2008-06-01 00:00:00
, but on that day the clocks go forward right then, so I'm gonna error".Adam Cameron
testZonedDateTime = java {
import java.time.format.DateTimeFormatter;
import java.time.ZonedDateTime;
import java.time.ZoneId;
public class TestZonedDateTime {
public String getControlDateTimeAsString() { // 2022-06-01 00:00:00
return getFormatedZonedDateTime(2022);
}
public String getDaylightSavingSwitchoverDateTimeAsString() { // 2008-06-01 00:00:00
return getFormatedZonedDateTime(2008);
}
private String getFormatedZonedDateTime(int year) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss");
ZonedDateTime dlsChangeOverTime = ZonedDateTime.of(year, 6, 1, 0, 0, 0, 0, ZoneId.of("Asia/Karachi"));
return formatter.format(dlsChangeOverTime);
}
}
}
writeOutput(testZonedDateTime.getControlDateTimeAsString() & "<br>") // 2022-06-01 00:00:00 NB: hour is **0**
writeOutput(testZonedDateTime.getDaylightSavingSwitchoverDateTimeAsString() & "<br>") // 2008-06-01 01:00:00 NB: hour is **1**
I also tested PHP, and it behaves the same as Java and Lucee. I got a mate to test C++ and it also is clever enough to work out what the code is asking for.
My conclusion is that this is a bug in CF.
Someone on that Stack Overflow raised a ticket for it (https://tracker.adobe.com/#/view/CF-4213572), but the underlying cause is slightly obscured by their example. Initially I piped-up saying "not a bug", but... I've changed my mind now.
I'm left wondering if there is any legit basis for the current CF behaviour to not be considered a bug?Mark Takata (Adobe)
06/06/2022, 4:24 PM