DST woes

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Posts: 44
Joined: Fri May 16, 2008 1:26 am

DST woes

Post by pderocco » Sat Sep 22, 2018 8:12 am

I'm having a devil of a time converting a broken-down (e.g., dateItems format) UTC time into seconds since the Unix epoch. The convert command assumes all time formats except seconds are in local time. It should be possible to do something like this:

Code: Select all

convert t from dateItems to internet time
put 0 into word -1 of t
convert t from internet time to seconds
This works most of the time but fails during that one non-existent hour during the spring forward transition. When I give it a time in hour 2, the first conversion says "that doesn't exist" and wraps it back to hour 1, as part of its normalization algorithm. Since it usually does no conversion at all if given invalid input, I wonder why it decides to impose an arbitrary meaning on invalid input in this case.

The feature request is simple: a "utc" option that can be appended to any of the time formats except seconds (since that's already UTC), both for the source and the destination. Doing something like

Code: Select all

convert t from dateItems utc to seconds
would be so much cleaner, and internally more efficient because there would be no timezone awareness at all.

This also means it should be possible to do things like:

Code: Select all

convert t from long date and long time utc to long date and long time
just to do the timezone conversion without format conversion.

Google turns up a lot of old threads where LiveCode users have struggled with converting time formats without it assuming that the times are local. And no one had a clean solution that didn't involve a bunch of code, or that didn't still fail during the "spring forward" hour.

VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8482
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

Re: DST woes

Post by FourthWorld » Sat Sep 22, 2018 8:29 am

Most good discussions of handing time zones are long.
Richard Gaskin
LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Feature Proposals”