chrono icon indicating copy to clipboard operation
chrono copied to clipboard

How to ignore zero padding for parsing the timezone offset?

Open sueskind opened this issue 2 years ago • 1 comments
trafficstars

I want to parse the following example string: "03:00 +3" where +3 is the timezone offset, i.e. the format %#z or %:::z but without leading zeros.

I have already tried the format specifiers

  • %z, %:z, %::z, %:::z and %#z
  • %-z, %-:z, %-::z, %-:::z and %-#z

but I always get either premature end of input or bad or unsupported format string errors.

How can I specify this format?

sueskind avatar May 09 '23 12:05 sueskind

It is currently not possible.

Two weeks ago I just happened to work on a branch to add support for formatting and parsing this. https://github.com/pitdicker/chrono/tree/offset_formatting. But I currently have a bit to much code in flight :smile:, better to get that merged or rejected first.

The idea is to support padding with -, optional minutes or seconds by placing a ? between : from where it should be optional, and to use # to allow Z for 00:00.

pitdicker avatar May 09 '23 13:05 pitdicker