|
| 1 | +featured: true |
| 2 | +handle: iso8601-date |
| 3 | +title: ISO 8601 Date Format |
| 4 | +tags: |
| 5 | +- date |
| 6 | +todo: "Handle millis, missing separators, etc." |
| 7 | +variations: |
| 8 | + - title: "ISO 8601 Complete" |
| 9 | + description: "from the [Intervals Blog](https://www.myintervals.com/blog/iso-8601-date-validation/)" |
| 10 | + regex: '^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$' |
| 11 | + inputs: |
| 12 | + - "2009-12T12:34" |
| 13 | + - "2009" |
| 14 | + - "2009-05-19" |
| 15 | + - "2009-05-19" |
| 16 | + - "20090519" |
| 17 | + - "2009123" |
| 18 | + - "2009-05" |
| 19 | + - "2009-123" |
| 20 | + - "2009-222" |
| 21 | + - "2009-001" |
| 22 | + - "2009-W01-1" |
| 23 | + - "2009-W51-1" |
| 24 | + - "2009-W511" |
| 25 | + - "2009-W33" |
| 26 | + - "2009W511" |
| 27 | + - "2009-05-19" |
| 28 | + - "2009-05-19 00:00" |
| 29 | + - "2009-05-19 14" |
| 30 | + - "2009-05-19 14:31" |
| 31 | + - "2009-05-19 14:39:22" |
| 32 | + - "2009-05-19T14:39Z" |
| 33 | + - "2009-W21-2" |
| 34 | + - "2009-W21-2T01:22" |
| 35 | + - "2009-139" |
| 36 | + - "2009-05-19 14:39:22-06:00" |
| 37 | + - "2009-05-19 14:39:22+0600" |
| 38 | + - "2009-05-19 14:39:22-01" |
| 39 | + - "20090621T0545Z" |
| 40 | + - "2007-04-06T00:00" |
| 41 | + - "2007-04-05T24:00" |
| 42 | + - "2010-02-18T16:23:48.5" |
| 43 | + - "2010-02-18T16:23:48,444" |
| 44 | + - "2010-02-18T16:23:48,3-06:00" |
| 45 | + - "2010-02-18T16:23.4" |
| 46 | + - "2010-02-18T16:23,25" |
| 47 | + - "2010-02-18T16:23.33+0600" |
| 48 | + - "2010-02-18T16.23334444" |
| 49 | + - "2010-02-18T16,2283" |
| 50 | + - "2009-05-19 143922.500" |
| 51 | + - "2009-05-19 1439,55" |
| 52 | + - title: "ISO 8601 Date (standalone)" |
| 53 | + regex: '^\d{4}-\d{2}-\d{2}$' |
| 54 | + inputs: |
| 55 | + - "2020-01-01" |
| 56 | + - "2020-02-29" |
| 57 | + - "2020-03-15" |
| 58 | + - "2020-04-30" |
| 59 | + - "2020-05-01" |
| 60 | + - "2020-06-15" |
| 61 | + - "2020-07-31" |
| 62 | + - "2020-08-01" |
| 63 | + - "2020-09-15" |
| 64 | + - "2020-10-31" |
| 65 | + - "2020-11-01" |
| 66 | + - "2020-12-15" |
| 67 | + - title: "ISO 8601 Date (inline)" |
| 68 | + regex: '\b\d{4}-\d{2}-\d{2}\b' |
| 69 | + inputs: |
| 70 | + - "My birthday is on 2020-01-01." |
| 71 | + - "I was born on 1970-01-01." |
| 72 | + - "The Ides of March is on 2020-03-15." |
| 73 | + - "2020-04-30 is the last day of the month." |
| 74 | + - "2020-05-01 is the first day of the month." |
| 75 | + - "2020-06-15 is halfway through the month." |
| 76 | + - "2020-07-31 is the last day of the month." |
| 77 | + - "2020-08-01 is the first day of the month." |
| 78 | + - "2020-09-15 is halfway through the month." |
| 79 | + - "2020-10-31 is Halloween." |
| 80 | + - "2020-11-01 is the day after Halloween." |
| 81 | + - "2020-12-15 is halfway through the month." |
| 82 | + - title: "ISO 8601 date+time (standalone)" |
| 83 | + regex: '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$' |
| 84 | + inputs: |
| 85 | + - "2020-01-01T00:00:00" |
| 86 | + - "2020-02-29T12:34:56" |
| 87 | + - "2020-03-15T23:59:59" |
| 88 | + - "2020-04-30T01:23:45" |
| 89 | + - "2020-05-01T12:34:56" |
| 90 | + - "2020-06-15T23:59:59" |
| 91 | + - "2020-07-31T01:23:45" |
| 92 | + - "2020-08-01T12:34:56" |
| 93 | + - "2020-09-15T23:59:59" |
| 94 | + - "2020-10-31T01:23:45" |
| 95 | + - "2020-11-01T12:34:56" |
| 96 | + - "2020-12-15T23:59:59" |
| 97 | + - title: "ISO 8601 simple date+time (inline)" |
| 98 | + regex: '\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\b' |
| 99 | + inputs: |
| 100 | + - "My birthday is on 2020-01-01T00:00:00." |
| 101 | + - "I was born on 1970-01-01T00:00:00." |
| 102 | + - "The Ides of March is on 2020-03-15T23:59:59." |
| 103 | + - "2020-04-30T01:23:45 is the last day of the month." |
| 104 | + - "2020-05-01T12:34:56 is the first day of the month." |
| 105 | + - "2020-06-15T23:59:59 is halfway through the month." |
| 106 | + - "2020-07-31T01:23:45 is the last day of the month." |
| 107 | + - "2020-08-01T12:34:56 is the first day of the month." |
| 108 | + - "2020-09-15T23:59:59 is halfway through the month." |
| 109 | + - "2020-10-31T01:23:45 is Halloween." |
| 110 | + - "2020-11-01T12:34:56 is the day after Halloween." |
| 111 | + - "2020-12-15T23:59:59 is halfway through the month." |
0 commit comments