@@ -12,7 +12,7 @@ extension type JSDate._(JSObject _) implements JSObject {
1212 /// The [Date constructor] that returns the current date and time.
1313 ///
1414 /// [Date constructor] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
15- external JSDate .now ();
15+ external JSDate .nowAsDate ();
1616
1717 /// The [Date constructor] with the number of milliseconds since the epoch of
1818 /// January 1, 1970, UTC.
@@ -24,20 +24,83 @@ extension type JSDate._(JSObject _) implements JSObject {
2424 ///
2525 /// [Date constructor] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
2626 /// [from a string] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#date_string
27- external JSDate .parse (String dateString);
27+ external JSDate .parseAsDate (String dateString);
2828
2929 /// The [Date constructor] that copies its value [from an existing Date] .
3030 ///
3131 /// [Date constructor] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
3232 /// [from an existing Date] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#date_object
3333 external JSDate .from (JSDate other);
3434
35- /// The [Date constructor] that uses [individual component integers] .
35+ /// The [Date constructor] that uses [individual component integers] ,
36+ /// interpreted in the local time zone.
3637 ///
3738 /// [Date constructor] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
3839 /// [individual component integers] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#individual_date_and_time_component_values
39- external JSDate (int year, int month,
40- [int ? day, int ? hours, int ? minutes, int ? seconds, int ? milliseconds]);
40+ external JSDate .localDate (
41+ int year,
42+ int month, [
43+ int ? day,
44+ int ? hours,
45+ int ? minutes,
46+ int ? seconds,
47+ int ? milliseconds,
48+ ]);
49+
50+ /// The [Date constructor] that uses [individual component integers] ,
51+ /// interpreted in the UTC time zone.
52+ ///
53+ /// [Date constructor] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
54+ /// [individual component integers] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#individual_date_and_time_component_values
55+ factory JSDate .utcDate (
56+ int year,
57+ int month, [
58+ int ? day,
59+ int ? hours,
60+ int ? minutes,
61+ int ? seconds,
62+ int ? milliseconds,
63+ ]) {
64+ var ms = switch ((day, hours, minutes, seconds, milliseconds)) {
65+ (_, _, _, _, var milliseconds? ) => JSDate .utcAsMillisecondsSinceEpoch (
66+ year,
67+ month,
68+ day,
69+ hours,
70+ minutes,
71+ seconds,
72+ milliseconds,
73+ ),
74+ (_, _, _, var seconds? , _) => JSDate .utcAsMillisecondsSinceEpoch (
75+ year,
76+ month,
77+ day,
78+ hours,
79+ minutes,
80+ seconds,
81+ ),
82+ (_, _, var minutes? , _, _) => JSDate .utcAsMillisecondsSinceEpoch (
83+ year,
84+ month,
85+ day,
86+ hours,
87+ minutes,
88+ ),
89+ (_, var hours? , _, _, _) => JSDate .utcAsMillisecondsSinceEpoch (
90+ year,
91+ month,
92+ day,
93+ hours,
94+ ),
95+ (var day? , _, _, _, _) => JSDate .utcAsMillisecondsSinceEpoch (
96+ year,
97+ month,
98+ day,
99+ ),
100+ _ => JSDate .utcAsMillisecondsSinceEpoch (year, month),
101+ };
102+ return JSDate .fromMillisecondsSinceEpoch (ms);
103+ }
41104
42105 /// Dee [`Date.now()`] .
43106 ///
@@ -55,13 +118,15 @@ extension type JSDate._(JSObject _) implements JSObject {
55118 ///
56119 /// [`Date.utc()`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC
57120 @JS ('UTC' )
58- external static int utc (int year,
59- [int ? month,
60- int ? day,
61- int ? hours,
62- int ? minutes,
63- int ? seconds,
64- int ? milliseconds]);
121+ external static int utcAsMillisecondsSinceEpoch (
122+ int year, [
123+ int ? month,
124+ int ? day,
125+ int ? hours,
126+ int ? minutes,
127+ int ? seconds,
128+ int ? milliseconds,
129+ ]);
65130
66131 /// See [`Date.getDate()`] and [`Date.setDate()`] .
67132 ///
@@ -81,14 +146,10 @@ extension type JSDate._(JSObject _) implements JSObject {
81146 /// [`Date.getDay()`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay
82147 /// [`Date.setDay()`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDay
83148 int get day => _getDay ();
84- set day (int value) => _setDay (value);
85149
86150 @JS ('getDay' )
87151 external int _getDay ();
88152
89- @JS ('setDay' )
90- external void _setDay (int value);
91-
92153 /// See [`Date.getFullYear()`] and [`Date.setFullYear()`] .
93154 ///
94155 /// [`Date.getFullYear()`] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear
0 commit comments