/iso8601

A small app to test and play around with some valid ISO8601 representations.

Primary LanguageJavaScript

ISO8601 Playground

A small app to test and play around with some valid ISO8601 representations.

I make no claims to it being a perfect implementation of the spec. It will accept some invalid inputs and I'm sure there are some valid inputs it misinterprets.

I'm also not trying to cover all edge cases around date/time handling. It just uses Javascript Date objects internally so any limitations will be inherited from that.

You can enter some text like 2021-06 and it will give you two instants representing the range covered by the ISO8601 input. In this case greater than or equal to (at or after) midnight on the 1st June 2021 and less than (before) midnight on 1st July.

When designing hobby APIs I tend to use ISO8601 ranges for specifying data periods, this helped me play around with some of the more advanced ISO8601 features.

Examples

Date

2
20
202
2021
2021018
20210118
2021W03
2021W031
2021-01
2021-018
2021-01-18
2021-W03
2021-W03-1
+2021-018
+2021-01-18
+2021-W03
+2021-W03-1

DateTime

2021018T10
20210118T10
2021W031T10
2021018T10.5
20210118T10.5
2021W031T10.5
2021018T1010
20210118T1010
2021W031T1010
2021018T1010.5
20210118T1010.5
2021W031T1010.5
2021018T101010
20210118T101010
2021W031T101010
2021018T101010.5
20210118T101010.5
2021W031T101010.5
2021-018T10
2021-01-18T10
2021-W03-1T10
2021-018T10.5
2021-01-18T10.5
2021-W03-1T10.5
2021-018T10:10
2021-01-18T10:10
2021-W03-1T10:10
2021-018T10:10.5
2021-01-18T10:10.5
2021-W03-1T10:10.5
2021-018T10:10:10
2021-01-18T10:10:10
2021-W03-1T10:10:10
2021-018T10:10:10.5
2021-01-18T10:10:10.5
2021-W03-1T10:10:10.5

Period

P1Y
P1.5Y
P1M
P15Y2.5M
PT1H
PT1.5M

Interval

DateTime/Period

2021-018/P1W
2021-01-18/P1W
2021-W03-1/P1W
2021-018T14/P1W
2021-01-18T14/P1W
2021-W03-1T14/P1W
2021-018/PT9H
2021-01-18/PT9H
2021-W03-1/PT9H
2021-018T14/PT9H
2021-01-18T14/PT9H
2021-W03-1T14/PT9H

DateTime/EndDateTime

2021-018/021
2021-01-18/21
2021-01-18/02-14
2021-W03-1/4
2021-W03-1/W01-2
2021-01-18/2022-02-14
2021-01-18T04:30/06:15

Period/DateTime

P1W/2021-018
P1W/2021-01-18
P1W/2021-W03-1
P1W/2021-018T14
P1W/2021-01-18T14
P1W/2021-W03-1T14
PT9H/2021-018
PT9H/2021-01-18
PT9H/2021-W03-1
PT9H/2021-018T14
PT9H/2021-01-18T14
PT9H/2021-W03-1T14

Repeating Interval

R/2021-018/P1W
R/2021-018/021
R/P1W/2021-018
R10/2021-018/P1W
R10/2021-018/021
R10/P1W/2021-018

Read More