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

Support parsing with timezone location similar to time.ParseInLocation and detect timezone presence in string #25

Closed
indexjoseph opened this issue Jul 8, 2024 · 1 comment · Fixed by #28

Comments

@indexjoseph
Copy link

indexjoseph commented Jul 8, 2024

Is your feature request related to a problem? Please describe.

Currently, in #3008 we're trying to use this ISO8601 library to allow a user to specify a start and end time, but we also have a timezone field. Preferably when the user is using ISO8601 format we'd like them to specify it without a timezone (e.g. 2024-07-08T16:36:59) and specify a timezone in the designated .timezone field. However if they choose to specify a timezone in the start and/or end time and a timezone field value then we'd like for that start/end time's timezone to override the timezone field, thus we need a way to determine whether or not the formatted string has a timezone.

With the current implementation parsing defaults the timezone to UTC and doesn't allow users to specify a timezone. A function similar to the time library's ParseInLocation would allow for us to parse the ISO8601 time in a specified zone.
In addition a way to allow us to determine whether or not the user specified a timezone in the ISO8601 formatted string (e.g., 2024-07-08T12:19:50.1-04:00, where -04:00 is the offset/timezone), this would allow us determine whether we should be parsing with the timezone field.

Describe alternatives you've considered

An alternative approach would be to take the parsed ISO8601 time provided and use time.Date() to place it in the correct timezone after it's parsed (instead of the default UTC).

@indexjoseph
Copy link
Author

We've come up with a solution that no longer requires ISO8601 format, however, I still believe a ParseInLocation function would be a nice-to-have for this library.

@relvacode relvacode linked a pull request Nov 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant