pendulum icon indicating copy to clipboard operation
pendulum copied to clipboard

ISO8601 Interval Separator

Open volks73 opened this issue 2 years ago • 0 comments

Pull Request Check List

  • [X] Added tests for changed code.
  • [X] 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.

volks73 avatar Mar 31 '22 21:03 volks73