Repository navigation
Datetime range ignores +/-hh:mm timezone ISO format specification #638
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
When adding time entries to Timewarrior, the +/-hh:mm timezone ISO format specification seems to be ignored, even though it is mentioned as a valid method in both man 7 timew-dates and the online documentation.
Details
There is no difference in behavior between adding a time entry with a timezone set to +00:00 (UTC):
$ timew track 2024-10-23T13:02:10+00:00 - 2024-10-23T13:32:10+00:00 'Some task'
Recorded "Some task"
Started 2024-10-23T13:02:10
Ended 32:10
Total 0:30:00
$ timew summary :ids
Wk Date Day ID Tags Start End Time Total
W43 2024-10-23 Wed @1 Some task 13:02:10 13:32:10 0:30:00
$ timew @1 export
[
{"id":1,"start":"20241023T090210Z","end":"20241023T093210Z","tags":["Some task"]}
]Or like this, with the timezone set to +04:00 (Asia/Tbilisi):
$ timew track 2024-10-23T13:02:10+04:00 - 2024-10-23T13:32:10+04:00 'Some task'
Recorded "Some task"
Started 2024-10-23T13:02:10
Ended 32:10
Total 0:30:00
$ timew summary :ids
Wk Date Day ID Tags Start End Time Total
W43 2024-10-23 Wed @1 Some task 13:02:10 13:32:10 0:30:00
$ timew @1 export
[
{"id":1,"start":"20241023T090210Z","end":"20241023T093210Z","tags":["Some task"]}
]Expected behavior
Setting a datetime range with a valid timezone format should result in a correct datetime database entry, including the specified timezone if provided.
Environment
$ timew --version
1.7.1
$ python --version
Python 3.12.7
$ uname -a
Linux host 6.11.4-arch2-1 #1 SMP PREEMPT_DYNAMIC Sun, 20 Oct 2024 18:20:12 +0000 x86_64 GNU/Linux
$ timedatectl
Local time: Wed 2024-10-23 20:36:51 +04
Universal time: Wed 2024-10-23 16:36:51 UTC
RTC time: Wed 2024-10-23 16:36:51
Time zone: Asia/Tbilisi (+04, +0400)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
smemsh commentedon Oct 23, 2024
They are different for me:
I'm using timewarrior build from d389bba
smemsh commentedon Oct 23, 2024
Come to think of it, the exported zulu timestrings seem to be wrong anyways, but for a different reason: they should only differ by 4 hours (+00:00 vs +04:00), but they differ by 11 hours?!? 🤔
smemsh commentedon Oct 23, 2024
they are determined correctly by libshared:
feels like I'm missing something, but not sure what.
d2718nis commentedon Oct 24, 2024
Built it from sources (d389bba and GothenburgBitFactory/libshared@a63fa35), here are the results:
$ ./src/timew --version 1.7.1-dev $ t=(2024-10-23T13:{02,32}:10+0{0,4}:00) $ ./src/timew track ${t[0]} - ${t[2]} :yes Recorded Started 2024-10-23T13:02:10 Ended 32:10 Total 0:30:00 $ ./src/timew track ${t[1]} - ${t[3]} You cannot overlap intervals. Correct the start/end time, or specify the :adjust hint. $ ./src/timew export [ {"id":1,"start":"20241023T090210Z","end":"20241023T093210Z"} ]But then using +1hr:
This is also calculated correctly for me:
I feel like it is related to
TZenv var not being set on my system, should it though? Here's an example:smemsh commentedon Oct 24, 2024
TZ=UTCwas only becausetask calcwould print in the localized time (ie your /etc/localtime), and for the purposes of display here I wanted to show what timezone was being used for output. Setting the time zone should make no difference fortimew trackif you are specifying the time zone of the input using the+syntax, which should be an absolute time. If it does, that seems like a bug.Indeed it does:
I think it is definitely a bug. The local timezone should only be used when we aren't providing the timezone of the input date in the date itself.