@@ -32,3 +32,39 @@ test("fractional seconds", () => {
32
32
formatRfc7231 ( Temporal . Instant . from ( "1968-06-07T01:23:45.123456789Z" ) ) ,
33
33
) . toEqual ( "Fri, 07 Jun 1968 01:23:45 GMT" ) ;
34
34
} ) ;
35
+
36
+ test ( "valid range of year" , ( ) => {
37
+ expect ( formatRfc7231 ( Temporal . Instant . from ( "0000-01-01T00:00:00Z" ) ) ) . toEqual (
38
+ "Sat, 01 Jan 0000 00:00:00 GMT" ,
39
+ ) ;
40
+ expect (
41
+ formatRfc7231 ( Temporal . ZonedDateTime . from ( "0000-01-01T00:00:00Z[UTC]" ) ) ,
42
+ ) . toEqual ( "Sat, 01 Jan 0000 00:00:00 GMT" ) ;
43
+ expect ( formatRfc7231 ( Temporal . Instant . from ( "9999-12-31T00:00:00Z" ) ) ) . toEqual (
44
+ "Fri, 31 Dec 9999 00:00:00 GMT" ,
45
+ ) ;
46
+ expect (
47
+ formatRfc7231 ( Temporal . ZonedDateTime . from ( "9999-12-31T00:00:00Z[UTC]" ) ) ,
48
+ ) . toEqual ( "Fri, 31 Dec 9999 00:00:00 GMT" ) ;
49
+ } ) ;
50
+
51
+ test ( "invalid range of year" , ( ) => {
52
+ expect ( ( ) => {
53
+ formatRfc7231 ( Temporal . Instant . from ( "-000001-12-31T23:59:59Z" ) ) ;
54
+ } ) . toThrow ( ) ;
55
+ expect ( ( ) => {
56
+ formatRfc7231 ( Temporal . ZonedDateTime . from ( "-000001-12-31T23:59:59Z[UTC]" ) ) ;
57
+ } ) . toThrow ( ) ;
58
+ expect ( ( ) => {
59
+ formatRfc7231 ( Temporal . Instant . from ( "-100000-01-01T00:00:00Z" ) ) ;
60
+ } ) . toThrow ( ) ;
61
+ expect ( ( ) => {
62
+ formatRfc7231 ( Temporal . ZonedDateTime . from ( "-100000-01-01T00:00:00Z[UTC]" ) ) ;
63
+ } ) . toThrow ( ) ;
64
+ expect ( ( ) => {
65
+ formatRfc7231 ( Temporal . Instant . from ( "+010000-01-01T00:00:00Z" ) ) ;
66
+ } ) . toThrow ( ) ;
67
+ expect ( ( ) => {
68
+ formatRfc7231 ( Temporal . ZonedDateTime . from ( "+010000-01-01T00:00:00Z[UTC]" ) ) ;
69
+ } ) . toThrow ( ) ;
70
+ } ) ;
0 commit comments