Open d2718nis opened 1 month ago
They are different for me:
$ t=(2024-10-23T13:{02,32}:10+0{0,4}:00)
$ echo ${times[@]} | fmt -1
2024-10-23T13:02:10+00:00
2024-10-23T13:02:10+04:00
2024-10-23T13:32:10+00:00
2024-10-23T13:32:10+04:00
$ timew track ${t[0]} - ${t[2]} :yes
Recorded
Started 2024-10-23T13:02:10
Ended 32:10
Total 0:30:00
$ timew track ${t[1]} - ${t[3]}
Recorded
Started 2024-10-23T02:02:10
Ended 32:10
Total 0:30:00
$ timew export
[
{"id":2,"start":"20241023T090210Z","end":"20241023T093210Z"},
{"id":1,"start":"20241023T200210Z","end":"20241023T203210Z"}
]
I'm using timewarrior build from d389bba7
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?!? :thinking:
they are determined correctly by libshared:
$ for off in 0 4
> do TZ=UTC task3 calc 2024-10-23T13:02:10+0$off:00; done
2024-10-23T13:02:10
2024-10-23T09:02:10
feels like I'm missing something, but not sure what.
Built it from sources (https://github.com/GothenburgBitFactory/timewarrior/commit/d389bba72cc38edf142efc481bfe6645c0b9610b and https://github.com/GothenburgBitFactory/libshared/commit/a63fa350413f598b3b55355a6460b7fd2efb2e69), 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:
$ ./src/timew track 2024-10-23T14:02:10+04:00 - 2024-10-23T14:32:10+04:00
Recorded
Started 2024-10-23T14:02:10
Ended 32:10
Total 0:30:00
$ ./src/timew export
[
{"id":2,"start":"20241023T090210Z","end":"20241023T093210Z"},
{"id":1,"start":"20241023T100210Z","end":"20241023T103210Z"}
]
This is also calculated correctly for me:
$ for off in 0 4; do TZ=UTC task calc 2024-10-23T13:02:10+0$off:00; done
2024-10-23T13:02:10
2024-10-23T09:02:10
I feel like it is related to TZ
env var not being set on my system, should it though? Here's an example:
$ env | grep TZ
$ TZ=UTC ./src/timew track ${t[0]} - ${t[2]} :yes
Recorded
Started 2024-10-23T13:02:10
Ended 32:10
Total 0:30:00
$ TZ=UTC ./src/timew track ${t[1]} - ${t[3]} :yes
Recorded
Started 2024-10-23T09:02:10
Ended 32:10
Total 0:30:00
$ ./src/timew export
[
{"id":2,"start":"20241023T090210Z","end":"20241023T093210Z"},
{"id":1,"start":"20241023T130210Z","end":"20241023T133210Z"}
]
TZ=UTC
was only because task calc
would 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 for timew track
if 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:
$ t=(2024-10-23T13:{02,32}:10+0{0,4}:00)
$ TZ=Asia/Tbilisi timew track ${t[0]} - ${t[2]} :yes
Recorded
Started 2024-10-23T13:02:10
Ended 32:10
Total 0:30:00
$ TZ=Asia/Tbilisi timew track ${t[1]} - ${t[3]}
You cannot overlap intervals. Correct the start/end time, or specify the :adjust hint.
$ rm -rf .local/share/timewarrior
$ TZ=US/Pacific timew track ${t[0]} - ${t[2]} :yes
Recorded
Started 2024-10-23T13:02:10
Ended 32:10
Total 0:30:00
$ TZ=US/Pacific timew track ${t[1]} - ${t[3]}
Recorded
Started 2024-10-23T02:02:10
Ended 32:10
Total 0:30:00
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.
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 bothman 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):Or like this, with the timezone set to
+04:00
(Asia/Tbilisi):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