on mobile … to your last point …I am ok with the parse failing so long as it throws an error that’s user visible in the piston.
Local Time Conversions Across DST Shift - Bug or My Design Flaw?
Unfortunately it doesn’t currently and it won’t with these changes since the function has a few levels of try/catch to handle alternate formats. We can’t easily distinguish here between expected exceptions (different format than supported by parse) and unexpected exceptions (known format but bad time zone). Java just pumps out an InvalidArgumentException
for both.
also dont need the ternary … which means we dont need to save the offsets to variables … this works:
if (!(dateOrTimeOrString =~ /(\s[A-Z]{3}((\+|\-)[0-9]{2}\:[0-9]{2}|\s[0-9]{4})?$)/)) {
def newDate = (new Date()).parse(dateOrTimeOrString + ' ' + formatLocalTime(now(), 'Z'))
return newDate + (location.timeZone.getOffset(now()) - location.timeZone.getOffset(newDate))
}
else
return (new Date()).parse(dateOrTimeOrString)
Basic test looks good! With no changes (never entered Edit mode) I ran a test with the earlier Piston and the results look great. Thanks a ton for your expertise and attention on this!
…and I assume this is expected behavior with use of he explicit time zone.
Since 12:00 AM 05-Nov-18 at my location is actually EST (vs the specified EDT), WebCoRE is properly knocking off an hour (“fall back”).