Skip to content

Is dround bugged or just confusing? (now with specific timezone) #158

@Git-Boy-Slim

Description

@Git-Boy-Slim

Hello,

I wanted to use the special now of dateutils.dround with a specific time zone (-z Europe/Berlin), but after testing it a little bit and comparing the results with date +'%FT%T' as the timestamp (which should be the same as timezoned now according to my understanding) I either discovered a bug or confused the hell out of me and didn't understand how dround is working in the first place.

Could you please explain to me why the results are different, even though the timestamps are initially the same?

This is what I've done:

$ dround -z Europe/Berlin now
    => 2024-04-11T01:24:33
$ dround "$(date +'%FT%T')"
    => 2024-04-11T01:24:33

The "rounded" times without any RNDSPEC (so the actual current time)

RNDSPEC=1s

$ dround -z Europe/Berlin now 1s -n
    => 2024-04-11T01:25:01
$ dround "$(date +'%FT%T')" 1s -n
    => 2024-04-11T01:25:01

now and date print the (imho) correct next occuring time with 01 in the seconds field.

RNDSPEC=1m

$ dround -z Europe/Berlin now 1m -n
    => 2024-04-11T02:01:33
$ dround "$(date +'%FT%T')" 1m -n
    => 2024-04-11T02:01:33

now and date both print the (imho) correct next occuring time with 01 in the minute field.

RNDSPEC=1h

$ dround -z Europe/Berlin now 1h -n
    => 2024-04-11T03:24:33
$ dround "$(date +'%FT%T')" 1h -n
    => 2024-04-12T01:24:33

now prints a time with 03 in the hour field even though 1h was specified. It also didn't change the day even though the current time is T01:24:33 and therefore next T01:**:** can only occur the next day.
The output of date on the other hand is what I expected from this RNDSPEC.

RNDSPEC=1d

$ dround -z Europe/Berlin now 1d -n
    => 2024-05-02T01:24:33
$ dround "$(date +'%FT%T')" 1d -n
    => 2024-05-01T01:24:33

now prints a time with 02 in the day field even though 1d was specified.
The output of date on the other hand is what I expected from this RNDSPEC.

RNDSPEC=1mo

$ dround -z Europe/Berlin now 1mo -n
    => 2025-01-11T00:24:33
$ dround "$(date +'%FT%T')" 1mo -n
    => 2025-01-11T01:24:33

now prints a (imho) correct next occuring date with 01 in the month field. But it shifts the time back one hour even though only 1d was specified.
The output of date on the other hand is what I expected from this RNDSPEC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions