Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ignore zero padding for parsing the timezone offset? #1055

Open
sueskind opened this issue May 9, 2023 · 1 comment
Open

How to ignore zero padding for parsing the timezone offset? #1055

sueskind opened this issue May 9, 2023 · 1 comment
Labels

Comments

@sueskind
Copy link

sueskind commented May 9, 2023

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?

@pitdicker
Copy link
Collaborator

pitdicker commented May 9, 2023

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 😄, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants