TimeZones-Alfred icon indicating copy to clipboard operation
TimeZones-Alfred copied to clipboard

Does not work with daylight saving time

Open chatchavan opened this issue 4 years ago • 3 comments

Example: Zurich (Switzerland) will begin the daylight saving time on 29 March 2020.

  • tz zurich 200329 01:59 → Vancouver 17:59 (This is correct.)
  • tz zurich 200329 03:00 → Vancouver 19:00 (The correct time in Vancouver should be 18:00.)

I have a quick look at the code and cannot find any file that keep the data on daylight saving time, so I guess that the change may be non-trivial.

chatchavan avatar Mar 17 '20 09:03 chatchavan

This seems like a pretty big issue.

mhkeller avatar Apr 06 '20 21:04 mhkeller

This seems like a pretty big issue.

I don't think it's is critical problem - from top of my head this can happen only when setting a date in the query. Otherwise (when asking a time for today), it should be working fine.

Still worth to check though.

Best regards, Jarek

jaroslawhartman avatar Apr 07 '20 05:04 jaroslawhartman

Took a look at timezone_list.sh and from the code snippet below:

#
# create source date
#
if [ 'tm' = "$date_modification_search" -o 'tomorrow' = "$date_modification_search" ]
then
    dateToConvert=$(date -v +1d +%Y%m%d)
elif [[ "$date_modification_search" =~ ^[0-9]+d$ ]]
...

(The full date handling logic is in timezone_list.sh:72-99)

Whenever a date is entered, the script uses the -v flag for the date command to create an offset. From the date man page under the -v flag:

When a date is adjusted to a specific value or in units greater than hours, daylight savings time considerations are ignored. Adjustments in units of hours or less honor daylight saving time. So, assuming the current date is March 26, 0:30 and that the DST adjustment means that the clock goes forward at 01:00 to 02:00, using -v +1H will adjust the date to March 26, 2:30. Likewise, if the date is October 29, 0:30 and the DST adjustment means that the clock goes back at 02:00 to 01:00, using -v +3H will be necessary to reach October 29, 2:30.

So seems like you're right @jaroslawhartman, this is only a problem when the date is entered. As shown below, without a date offset that flag isn't used so DST considerations are kept.

else
    # fallback that also covers 't' and 'today'
    dateToConvert=$(date +%Y%m%d)
fi

mohoromitch avatar May 03 '20 07:05 mohoromitch