|
2020-03-04
| ||
| 17:13 | • Closed ticket [5116bce4bc]: clock: the distance between "2004-03-28 01:00:0... artifact: 9282e26440 user: sebres | |
| 15:28 | • New ticket [5116bce4bc]. artifact: 8f6843e777 user: ierschterlich | |
clock: the distance between "2004-03-28 01:00:00" and "2004-03-28 03:00:00" is only ONE hour
# The clock values of "2004-03-28 01:00:00" and "2004-03-28 02:00:00" are the same
(bin) 1 % set date [clock scan "2004-03-28 01:00:00" -format {%Y-%m-%d %H:%M:%S}]
1080432000
(bin) 2 % set date [clock scan "2004-03-28 02:00:00" -format {%Y-%m-%d %H:%M:%S}]
1080432000
# When converting this value back into some readable form, this gives 01:00:00:
(bin) 13 % clock format 1080432000 -format {%Y-%m-%d %H:%M:%S}
2004-03-28 01:00:00
# But when adding 1 hour, this gives 03:00:00 (instead of 02:00:00)
(bin) 15 % clock format [clock add 1080432000 1 hour] -format {%Y-%m-%d %H:%M:%S}
2004-03-28 03:00:00
> The clock values of "2004-03-28 01:00:00" and "2004-03-28 02:00:00" are the same
It is time zone related thing, if you don't specify a timezone (or -gmt 1) clock will use default timezone (and I assume you're in CET time zone), and the time 02:00:00 doesn't exist at 2004-03-28 in this zone at all. It going to DST switch at 02:00 to 03:00, so you are unable to get this time.
Either specify UTC/GMT or correct (or validate) the time you want to scan.
% clock format [expr {1080435599 + 0}] -format {%Y-%m-%d %H:%M:%S}
2004-03-28 01:59:59
% clock format [expr {1080435599 + 1}] -format {%Y-%m-%d %H:%M:%S}
2004-03-28 03:00:00
At the moment clock scan does not validate the time at all (it is simply adjusted to the near valid time). In the future clock-version we'll hopefully get -valid parameter to enable validation of specified date-time.
See [3475995] for more information.
> When converting this value back into some readable form, this gives 01:00:00... But when adding 1 hour, this gives 03:00:00 (instead of 02:00:00)
Sure, because in your timezone it is really so due to DST time switch (see my example above). In GMT/UTC it have neither a DST-time hole nor a DST-time jump by such conversion.
Thus closed as incorrect.