Skip to content

Commit 7a645dd

Browse files
committed
Allow UT as timezone for RFC 850
1 parent 3ab93b0 commit 7a645dd

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

lib/src/pick_datetime.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enum PickDateFormat {
3535
/// - `Fri Feb 15 14:45:01 2013`
3636
ANSI_C_asctime,
3737

38-
/// A valid but rarely used format for HTTP date headers
38+
/// A valid but rarely used format for HTTP date headers, and cookies
3939
///
4040
/// https://datatracker.ietf.org/doc/html/rfc850, obsolete by
4141
/// [RFC 1036](https://datatracker.ietf.org/doc/html/rfc1036)
@@ -196,8 +196,8 @@ extension NullableDateTimePick on Pick {
196196
final value = required().value;
197197
if (value is! String) return null;
198198
try {
199-
final rfc850Regex =
200-
RegExp(r'^\s*(\S+),\s*(\d+)-(\S{3})-(\d+)\s+(\d+):(\d+):(\d+)\s*GMT');
199+
final rfc850Regex = RegExp(
200+
r'^\s*(\S+),\s*(\d+)-(\S{3})-(\d+)\s+(\d+):(\d+):(\d+)\s*(GMT|UT)');
201201
final match = rfc850Regex.firstMatch(value)!;
202202
final day = int.parse(match.group(2)!);
203203
final month = _months[match.group(3)!]!;

test/src/pick_datetime_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,10 @@ void main() {
424424
);
425425
});
426426

427-
test('only allows GMT', () {
427+
test('only allows GMT/UT as time zone', () {
428+
pick('Sunday, 06-Nov-94 08:49:37 GMT').asDateTimeOrThrow(); // ok
429+
pick('Sunday, 06-Nov-94 08:49:37 UT').asDateTimeOrThrow(); // ok
430+
428431
expect(
429432
() => pick('Sunday, 6-Nov-94 08:49:37 PST').asDateTimeOrThrow(),
430433
throwsA(pickException(

0 commit comments

Comments
 (0)