hroptatyr / dateutils

nifty command line date and time utilities; fast date calculations and conversion in the shell
http://www.fresse.org/dateutils/
Other
612 stars 40 forks source link

Use "now", "today" etc but in local time in ddiff #115

Closed konomikitten closed 3 years ago

konomikitten commented 3 years ago

now, today and the specials seem handy but they all give time stamps in UTC where as I am working with local time. So this is either a feature request to give us a way to use the specials but with local time values or a question on how to do that with the current version as I can't seem to find a way to make now be expressed in local time?

hroptatyr commented 3 years ago

Hi Konomi, did you see that you can do

$ dateconv now --zone 'Australia/Melbourne'

For today this wouldn't work as the date is time-less. You'd have to use now and -f %F.

The rationale behind this is part platform-independence (there's so many ways where local time can be specified) and part design: The tools are supposed to produce the same output given equal inputs on any system. Most of the tools, however, specifically allow to hand in a source time zone as well as a target time zone.

konomikitten commented 3 years ago

I mean I can do that with date as well but I'm looking to do:

dateutils.ddiff 2020-10-17T15:30+11:00 now -f "%d %H"

Rather than having to do:

dateutils.ddiff 2020-10-17T15:30+11:00 $(date --iso-8601=minutes) -f "%d %H"

Ideally as I stated originally it would be nice if ddiff allowed for using localtime rather than UTC?

hroptatyr commented 3 years ago

Yes well, I'd say:

$ dateutils.ddiff 2020-10-17T15:30 now -f "%d %H" --from-zone Australia/Melbourne

should work. Takes both times as Melbourne stamps.

konomikitten commented 3 years ago

Thanks that's what I was after I did see that flag in the manual for ddiff I just didn't realise it would apply to the special for now.

hroptatyr commented 3 years ago

No worries.