Skip to content

Commit

Permalink
Wednesday support for RFC 850
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim-Mazurok committed Jun 29, 2022
1 parent 6b47f20 commit c17f5f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/impl/regexParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function preprocessRFC2822(s) {
const rfc1123 =
/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,
rfc850 =
/^(Monday|Tuesday|Wedsday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,
/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,
ascii =
/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;

Expand Down
14 changes: 14 additions & 0 deletions test/datetime/regexParse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,20 @@ test("DateTime.fromHTTP() can parse RFC 850", () => {
});
});

test("DateTime.fromHTTP() can parse RFC 850 on Wednesday", () => {
const dt = DateTime.fromHTTP("Wednesday, 29-Jun-22 08:49:37 GMT");
expect(dt.isValid).toBe(true);
expect(dt.toUTC().toObject()).toEqual({
year: 2022,
month: 6,
day: 29,
hour: 8,
minute: 49,
second: 37,
millisecond: 0,
});
});

test("DateTime.fromHTTP() can parse ASCII dates with one date digit", () => {
const dt = DateTime.fromHTTP("Sun Nov 6 08:49:37 1994");
expect(dt.isValid).toBe(true);
Expand Down

0 comments on commit c17f5f6

Please # to comment.