Skip to content

Commit 1952873

Browse files
committed
Document datetime parsers
Fixes #46
1 parent 580b4ba commit 1952873

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,14 @@ pick(1).letOrNull((pick) => pick.value == 1 ? true : pick.value == 0 ? false : n
145145

146146
### `DateTime`
147147

148-
Accepts most common date formats such as `ISO 8601`. For more supported formats see [`DateTime.parse`](https://api.dart.dev/stable/1.24.2/dart-core/DateTime/parse.html).
148+
Accepts most common date formats such as `ISO 8601` (including `RFC 3339`), `RFC 1123` ([HTTP `date`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date) header, [RSS2](https://validator.w3.org/feed/docs/rss2.html) `pubDate`), `RFC 850` (including `RFC 1036`, `COOKIE`), `ANSI C asctime()`.
149149

150150
```dart
151-
pick('2020-03-01T13:00:00Z').asDateTimeOrNull(); // a valid DateTime object
152-
pick('20200227 13:27:00').asDateTimeOrThrow(); // a valid DateTime object
151+
pick('2021-11-01T11:53:15Z').asDateTimeOrNull(); // UTC
152+
pick('2021-11-01T11:53:15+0000').asDateTimeOrNull(); // ISO 8601
153+
pick('Monday, 01-Nov-21 11:53:15 UTC').asDateTimeOrThrow(); // RFC 850
154+
pick('Wed, 21 Oct 2015 07:28:00 GMT').asDateTimeOrThrow(); // RFC 1123
155+
pick('Sun Nov 6 08:49:37 1994').asDateTimeOrThrow(); // asctime()
153156
```
154157

155158
### `List`

lib/src/pick_datetime.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ enum PickDateFormat {
77
///
88
/// https://www.w3.org/TR/NOTE-datetime
99
///
10+
/// Also covers [RFC-3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6)
11+
///
1012
/// Example:
1113
/// - `2005-08-15T15:52:01+0000`
1214
ISO_8601,
1315

14-
/// The typical HTTP date header
16+
/// A typical format used in the web that's not ISO8601
1517
///
1618
/// [RFC-1123](http://tools.ietf.org/html/rfc1123) (specifically
1719
/// [RFC-5322 Section 3.3](https://datatracker.ietf.org/doc/html/rfc5322#section-3.3))
1820
/// based on [RFC-822](https://datatracker.ietf.org/doc/html/rfc822)
1921
///
20-
/// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date
21-
/// See https://www.rfc-editor.org/rfc/rfc2616#section-3.3
22+
/// Used as
23+
/// - HTTP date header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date, https://www.rfc-editor.org/rfc/rfc2616#section-3.3
24+
/// - RSS2 pubDate, lastBuildDate https://validator.w3.org/feed/docs/rss2.html
2225
///
2326
/// Example:
2427
/// - `Date: Wed, 21 Oct 2015 07:28:00 GMT`

0 commit comments

Comments
 (0)