chrono icon indicating copy to clipboard operation
chrono copied to clipboard

GNU coreutils `date`-like time zone formatting

Open jarkonik opened this issue 3 years ago • 1 comments

Pull request adds additional string formatting options for time zones using multiple colons as syntax, which are identical to formatting options in GNU coreutils date ( https://man7.org/linux/man-pages/man1/date.1.html )

This would fix https://github.com/uutils/coreutils/issues/3780

In addition to currently implemented %z and %:z PR adds 2 new date formatting options: %::z Offset from the local time to UTC with seconds. (+09:30:00 ) %:::z Offset from the local time to UTC without minutes. (+09)

jarkonik avatar Aug 06 '22 12:08 jarkonik

Would you mind documenting in the PR description the intended behavior?

djc avatar Aug 06 '22 13:08 djc

@jarkonik ping ? :)

sylvestre avatar Aug 16 '22 09:08 sylvestre

I've expanded the PR description a bit. If more information is needed please let me know what should I change/add.

jarkonik avatar Aug 16 '22 11:08 jarkonik

Thanks, this looks good to me.

djc avatar Aug 16 '22 18:08 djc

@esheppa any opinions?

djc avatar Aug 17 '22 09:08 djc

Looks good, just one thing I'd noticed is that potentially it could loop forever if the input was like %:::::::::: ...etc. I've set up a PR to @jarkonik which proposes two alternative implementations (one is commented out) - https://github.com/jarkonik/chrono/pull/1

My concern with the looping forever is that the strftime items can be used to validate user input, so it could be a DOS attack

esheppa avatar Aug 17 '22 12:08 esheppa

Thanks!

djc avatar Aug 17 '22 16:08 djc

Well done! Sorry for the question but how often do you release ? :)

sylvestre avatar Aug 17 '22 16:08 sylvestre