A lax Web news feed parser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

115 lines
3.9 KiB

RFC 3339 Zulu time:
input:
- '2020-03-05T23:08:55Z'
- '2020-03-05T23:08:55z'
- '2020-03-05t23:08:55Z'
- '2020-03-05t23:08:55z'
- '2020-03-05 23:08:55Z'
- '2020-03-05 23:08:55z'
output: '2020-03-05T23:08:55+00:00'
RFC 3339 UTC-4:
input:
- '2020-03-05T23:08:55-0400'
- '2020-03-05t23:08:55-0400'
- '2020-03-05 23:08:55-0400'
- '2020-03-05T23:08:55 -0400'
- '2020-03-05t23:08:55 -0400'
- '2020-03-05 23:08:55 -0400'
- '2020-03-05T23:08:55-04:00'
- '2020-03-05t23:08:55-04:00'
- '2020-03-05 23:08:55-04:00'
- '2020-03-05T23:08:55 -04:00'
- '2020-03-05t23:08:55 -04:00'
- '2020-03-05 23:08:55 -04:00'
output: '2020-03-05T23:08:55-04:00'
RFC 3339 UTC+11:
input:
- '2020-03-05T23:08:55+1100'
- '2020-03-05t23:08:55+1100'
- '2020-03-05 23:08:55+1100'
- '2020-03-05T23:08:55 +1100'
- '2020-03-05t23:08:55 +1100'
- '2020-03-05 23:08:55 +1100'
- '2020-03-05T23:08:55+11:00'
- '2020-03-05t23:08:55+11:00'
- '2020-03-05 23:08:55+11:00'
- '2020-03-05T23:08:55 +11:00'
- '2020-03-05t23:08:55 +11:00'
- '2020-03-05 23:08:55 +11:00'
output: '2020-03-05T23:08:55+11:00'
RFC 3339 with various precision:
input:
- '2020-03-05T23:08:00Z'
- '2020-03-05T23:08Z'
- '2020-03-05T23:08:00.0Z'
- '2020-03-05T23:08:00.000000000000Z'
output: '2020-03-05T23:08:00+00:00'
RFC 3339 with subseconds:
input:
- '2020-03-05T23:08:00.123456Z'
- '2020-03-05t23:08:00.123456Z'
- '2020-03-05 23:08:00.123456Z'
- '2020-03-05T23:08:00.123456z'
- '2020-03-05t23:08:00.123456z'
- '2020-03-05 23:08:00.123456z'
- '2020-03-05T23:08:00.123456+0000'
- '2020-03-05t23:08:00.123456+0000'
- '2020-03-05 23:08:00.123456+0000'
- '2020-03-05T23:08:00.123456+00:00'
- '2020-03-05t23:08:00.123456+00:00'
- '2020-03-05 23:08:00.123456+00:00'
- '2020-03-05T23:08:00.123456 +0000'
- '2020-03-05t23:08:00.123456 +0000'
- '2020-03-05 23:08:00.123456 +0000'
- '2020-03-05T23:08:00.123456 +00:00'
- '2020-03-05t23:08:00.123456 +00:00'
- '2020-03-05 23:08:00.123456 +00:00'
output: '2020-03-05T23:08:00.123456+00:00'
RFC 3339 without timezone:
input:
- '2020-03-05T23:08:55-0000'
- '2020-03-05T23:08:55-00:00'
- '2020-03-05T23:08:55 -0000'
- '2020-03-05T23:08:55 -00:00'
- '2020-03-05T23:08:55'
- '2020-03-05t23:08:55-0000'
- '2020-03-05t23:08:55-00:00'
- '2020-03-05t23:08:55 -0000'
- '2020-03-05t23:08:55 -00:00'
- '2020-03-05t23:08:55'
- '2020-03-05 23:08:55-0000'
- '2020-03-05 23:08:55-00:00'
- '2020-03-05 23:08:55 -0000'
- '2020-03-05 23:08:55 -00:00'
- '2020-03-05 23:08:55'
output: '2020-03-05T23:08:55-00:00'
RFC 3339 with invalid data:
input:
- '2020-02-31T23:08:55Z' # impossible date (February 31)
- '2020-02-28T25:08:55Z' # impossible hour
- '2020-02-28T23:65:55Z' # impossible minute
- '2020-02-28T23:08:74Z' # impossible second
- '2020-02-28T23:08:74+1300' # impossible hour in timezone
- '2020-02-28T23:08:74-1300' # impossible hour in timezone
- '2020-02-28T23:08:74+1165' # impossible minute in timezone
- '2020-02-28T23:08:74-1165' # impossible minute in timezone
output: null
RFC 3339 with invalid syntax:
input:
- '20-02-05T23:08:55Z'
- '2020-2-05T23:08:55Z'
- '2020-02-5T23:08:55Z'
- '2020-02-05T3:08:55Z'
- '2020-02-05T23:8:55Z'
- '2020-02-05T23:08:5Z'
- '2020-02-05T23:08:55.Z'
- '2020-02-05T23:08.0Z'
- '2020-02-05T23:08:55 UTC' # only numeric offset or "Z" are allowed for RFC 3339
output: null