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

ISO8601 Interval Separator #611

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

volks73
Copy link

@volks73 volks73 commented Mar 31, 2022

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

According to the Wikipedia entry for the ISO8601 format (I do not have access to the official specification):

Section 3.2.6 of ISO 8601-1:2019 notes that "A solidus may be replaced by a double hyphen ["--"] by mutual agreement of the communicating partners", and previous versions used notations like "2000--2002".[39] Use of a double hyphen instead of a solidus allows inclusion in computer filenames;[40] in common operating systems, a solidus is a reserved character and is not allowed in a filename.

A -- can be used as an alternative to / to separate the begin and end components of an interval. I would like to use the -- separator for my application where the / would cause issues, specifically in a URL and in a filename as mentioned in the Wikipedia article.

I saw that this excellent package is able to parse ISO8601 intervals, but only if the / is used. I was hoping to provide this PR to parse an interval if either the / or the -- is present.

I have added additional tests and documentation that also include parsing intervals without colons, :, or dashes, -, because it wasn't clear to me from the tests or documentation if the "compact" ISO8601 datetime strings could be used with intervals. I would like to use the "compact" strings for similar reasons of using them for filenames and colons, specifically, are special characters on some systems.

Christopher Field added 3 commits March 30, 2022 14:40
An interval is split on either a `/` or a `--`. According to the
Wikipedia entry on ISO8601 Intervals:

>Section 3.2.6 of ISO 8601-1:2019 notes that "A solidus may be replaced
>by a double hyphen ["--"] by mutual agreement of the communicating
>partners", and previous versions used notations like "2000--2002".[39]
>Use of a double hyphen instead of a solidus allows inclusion in computer
>filenames;[40] in common operating systems, a solidus is a reserved
>character and is not allowed in a filename.
Tests that parse the compact ISO8601 datetime format are added along
with copies of the same tests using the `--` instead of the `/`
separator. This ensures parity between parsing regardless of separator.

However, no test has been added if _both_ `--` and `/` appear in the text.
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 this pull request may close these issues.

None yet

1 participant