chrono
chrono copied to clipboard
How to ignore zero padding for parsing the timezone offset?
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,%:::zand%#z%-z,%-:z,%-::z,%-:::zand%-#z
but I always get either premature end of input or bad or unsupported format string errors.
How can I specify this format?
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.