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, robinmiller, kevinmiller

Post Reply
pderocco
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.
Ciao,
Paul

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

Re: DST woes

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

Most good discussions of handing time zones are long.
https://youtu.be/-5wpm-gesOY
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Post Reply

Return to “Feature Requests”