porffor 0.57.30 → 0.57.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,6 @@ export const __ecma262_TimeWithinDay = (t: number): number => t % 86400000;
|
|
14
14
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-daysinyear
|
15
15
|
export const __ecma262_DaysInYear = (y: number): number => {
|
16
16
|
// 1. Let ry be ℝ(y).
|
17
|
-
|
18
17
|
// 2. If (ry modulo 400) = 0, return 366𝔽.
|
19
18
|
if (y % 400 == 0) return 366;
|
20
19
|
|
@@ -36,21 +35,15 @@ export const __ecma262_DayFromYear = (y: number): number => {
|
|
36
35
|
// represent the number of years divisible by 1, 4, 100, and 400, respectively,
|
37
36
|
// that occur between the epoch and the start of year y.
|
38
37
|
// The number is negative if y is before the epoch.
|
39
|
-
|
40
38
|
// 3. Let numYears1 be (ry - 1970).
|
41
|
-
const numYears1: number = y - 1970;
|
42
|
-
|
43
39
|
// 4. Let numYears4 be floor((ry - 1969) / 4).
|
44
|
-
const numYears4: number = Math.floor((y - 1969) / 4);
|
45
|
-
|
46
40
|
// 5. Let numYears100 be floor((ry - 1901) / 100).
|
47
|
-
const numYears100: number = Math.floor((y - 1901) / 100);
|
48
|
-
|
49
41
|
// 6. Let numYears400 be floor((ry - 1601) / 400).
|
50
|
-
const numYears400: number = Math.floor((y - 1601) / 400);
|
51
|
-
|
52
42
|
// 7. Return 𝔽(365 × numYears1 + numYears4 - numYears100 + numYears400).
|
53
|
-
return 365 *
|
43
|
+
return 365 * (y - 1970)
|
44
|
+
+ Math.floor((y - 1969) / 4)
|
45
|
+
- Math.floor((y - 1901) / 100)
|
46
|
+
+ Math.floor((y - 1601) / 400);
|
54
47
|
};
|
55
48
|
|
56
49
|
// 21.4.1.7 TimeFromYear (y)
|
@@ -62,7 +55,6 @@ export const __ecma262_TimeFromYear = (y: number): number => 86400000 * __ecma26
|
|
62
55
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-yearfromtime
|
63
56
|
export const __ecma262_YearFromTime = (t: number): number => {
|
64
57
|
// 1. Return the largest integral Number y (closest to +∞) such that TimeFromYear(y) ≤ t.
|
65
|
-
|
66
58
|
// guess year with floor(t / (365.2425 * msPerDay)) + 1970
|
67
59
|
const y: number = Math.floor(t / 31556952000) + 1970;
|
68
60
|
|
@@ -94,45 +86,33 @@ export const __ecma262_InLeapYear = (t: number): number => __ecma262_DaysInYear(
|
|
94
86
|
export const __ecma262_MonthFromTime = (t: number): number => {
|
95
87
|
// 1. Let inLeapYear be InLeapYear(t).
|
96
88
|
const inLeapYear: number = __ecma262_InLeapYear(t);
|
97
|
-
|
98
89
|
// 2. Let dayWithinYear be DayWithinYear(t).
|
99
90
|
const dayWithinYear: number = __ecma262_DayWithinYear(t);
|
100
91
|
|
101
92
|
// 3. If dayWithinYear < 31𝔽, return +0𝔽.
|
102
93
|
if (dayWithinYear < 31) return 0;
|
103
|
-
|
104
94
|
// 4. If dayWithinYear < 59𝔽 + inLeapYear, return 1𝔽.
|
105
95
|
if (dayWithinYear < 59 + inLeapYear) return 1;
|
106
|
-
|
107
96
|
// 5. If dayWithinYear < 90𝔽 + inLeapYear, return 2𝔽.
|
108
97
|
if (dayWithinYear < 90 + inLeapYear) return 2;
|
109
|
-
|
110
98
|
// 6. If dayWithinYear < 120𝔽 + inLeapYear, return 3𝔽.
|
111
99
|
if (dayWithinYear < 120 + inLeapYear) return 3;
|
112
|
-
|
113
100
|
// 7. If dayWithinYear < 151𝔽 + inLeapYear, return 4𝔽.
|
114
101
|
if (dayWithinYear < 151 + inLeapYear) return 4;
|
115
|
-
|
116
102
|
// 8. If dayWithinYear < 181𝔽 + inLeapYear, return 5𝔽.
|
117
103
|
if (dayWithinYear < 181 + inLeapYear) return 5;
|
118
|
-
|
119
104
|
// 9. If dayWithinYear < 212𝔽 + inLeapYear, return 6𝔽.
|
120
105
|
if (dayWithinYear < 212 + inLeapYear) return 6;
|
121
|
-
|
122
106
|
// 10. If dayWithinYear < 243𝔽 + inLeapYear, return 7𝔽.
|
123
107
|
if (dayWithinYear < 243 + inLeapYear) return 7;
|
124
|
-
|
125
108
|
// 11. If dayWithinYear < 273𝔽 + inLeapYear, return 8𝔽.
|
126
109
|
if (dayWithinYear < 273 + inLeapYear) return 8;
|
127
|
-
|
128
110
|
// 12. If dayWithinYear < 304𝔽 + inLeapYear, return 9𝔽.
|
129
111
|
if (dayWithinYear < 304 + inLeapYear) return 9;
|
130
|
-
|
131
112
|
// 13. If dayWithinYear < 334𝔽 + inLeapYear, return 10𝔽.
|
132
113
|
if (dayWithinYear < 334 + inLeapYear) return 10;
|
133
114
|
|
134
115
|
// 14. Assert: dayWithinYear < 365𝔽 + inLeapYear.
|
135
|
-
|
136
116
|
// 15. Return 11𝔽.
|
137
117
|
return 11;
|
138
118
|
};
|
@@ -142,48 +122,35 @@ export const __ecma262_MonthFromTime = (t: number): number => {
|
|
142
122
|
export const __ecma262_DateFromTime = (t: number): number => {
|
143
123
|
// 1. Let inLeapYear be InLeapYear(t).
|
144
124
|
const inLeapYear: number = __ecma262_InLeapYear(t);
|
145
|
-
|
146
125
|
// 2. Let dayWithinYear be DayWithinYear(t).
|
147
126
|
const dayWithinYear: number = __ecma262_DayWithinYear(t);
|
148
|
-
|
149
127
|
// 3. Let month be MonthFromTime(t).
|
150
128
|
const month: number = __ecma262_MonthFromTime(t);
|
151
129
|
|
152
130
|
// 4. If month is +0𝔽, return dayWithinYear + 1𝔽.
|
153
131
|
if (month == 0) return dayWithinYear + 1;
|
154
|
-
|
155
132
|
// 5. If month is 1𝔽, return dayWithinYear - 30𝔽.
|
156
133
|
if (month == 1) return dayWithinYear - 30;
|
157
|
-
|
158
134
|
// 6. If month is 2𝔽, return dayWithinYear - 58𝔽 - inLeapYear.
|
159
135
|
if (month == 2) return dayWithinYear - 58 - inLeapYear;
|
160
|
-
|
161
136
|
// 7. If month is 3𝔽, return dayWithinYear - 89𝔽 - inLeapYear.
|
162
137
|
if (month == 3) return dayWithinYear - 89 - inLeapYear;
|
163
|
-
|
164
138
|
// 8. If month is 4𝔽, return dayWithinYear - 119𝔽 - inLeapYear.
|
165
139
|
if (month == 4) return dayWithinYear - 119 - inLeapYear;
|
166
|
-
|
167
140
|
// 9. If month is 5𝔽, return dayWithinYear - 150𝔽 - inLeapYear.
|
168
141
|
if (month == 5) return dayWithinYear - 150 - inLeapYear;
|
169
|
-
|
170
142
|
// 10. If month is 6𝔽, return dayWithinYear - 180𝔽 - inLeapYear.
|
171
143
|
if (month == 6) return dayWithinYear - 180 - inLeapYear;
|
172
|
-
|
173
144
|
// 11. If month is 7𝔽, return dayWithinYear - 211𝔽 - inLeapYear.
|
174
145
|
if (month == 7) return dayWithinYear - 211 - inLeapYear;
|
175
|
-
|
176
146
|
// 12. If month is 8𝔽, return dayWithinYear - 242𝔽 - inLeapYear.
|
177
147
|
if (month == 8) return dayWithinYear - 242 - inLeapYear;
|
178
|
-
|
179
148
|
// 13. If month is 9𝔽, return dayWithinYear - 272𝔽 - inLeapYear.
|
180
149
|
if (month == 9) return dayWithinYear - 272 - inLeapYear;
|
181
|
-
|
182
150
|
// 14. If month is 10𝔽, return dayWithinYear - 303𝔽 - inLeapYear.
|
183
151
|
if (month == 10) return dayWithinYear - 303 - inLeapYear;
|
184
152
|
|
185
153
|
// 15. Assert: month is 11𝔽.
|
186
|
-
|
187
154
|
// 16. Return dayWithinYear - 333𝔽 - inLeapYear.
|
188
155
|
return dayWithinYear - 333 - inLeapYear;
|
189
156
|
};
|
@@ -213,43 +180,15 @@ export const __ecma262_SecFromTime = (t: number): number => Math.floor(t / 1000)
|
|
213
180
|
// 1. Return 𝔽(ℝ(t) modulo ℝ(msPerSecond)).
|
214
181
|
export const __ecma262_msFromTime = (t: number): number => t % 1000;
|
215
182
|
|
216
|
-
|
217
|
-
// // 21.4.1.21 GetNamedTimeZoneOffsetNanoseconds (timeZoneIdentifier, epochNanoseconds)
|
218
|
-
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-getnamedtimezoneoffsetnanoseconds
|
219
|
-
// export const __ecma262_GetNamedTimeZoneOffsetNanoseconds = (timeZoneIdentifier: bytestring, epochNanoseconds: number /* BigInt (unused) */): number => {
|
220
|
-
// // 1. Assert: timeZoneIdentifier is "UTC".
|
221
|
-
|
222
|
-
// // 2. Return 0.
|
223
|
-
// return 0;
|
224
|
-
// };
|
225
|
-
|
226
|
-
// // 21.4.1.23 AvailableNamedTimeZoneIdentifiers ()
|
227
|
-
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-availablenamedtimezoneidentifiers
|
228
|
-
// export const __ecma262_AvailableNamedTimeZoneIdentifiers = (): bytestring[] => {
|
229
|
-
// // 1. If the implementation does not include local political rules for any time zones, then
|
230
|
-
// // a. Return « the Time Zone Identifier Record { [[Identifier]]: "UTC", [[PrimaryIdentifier]]: "UTC" } ».
|
231
|
-
// return [ 'UTC' ];
|
232
|
-
// };
|
233
|
-
|
234
|
-
// // 21.4.1.24 SystemTimeZoneIdentifier ()
|
235
|
-
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-systemtimezoneidentifier
|
236
|
-
// export const __ecma262_SystemTimeZoneIdentifier = (): bytestring => {
|
237
|
-
// // 1. If the implementation only supports the UTC time zone, return "UTC".
|
238
|
-
// return 'UTC';
|
239
|
-
// };
|
240
|
-
|
241
183
|
// 21.4.1.25 LocalTime (t)
|
242
184
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-localtime
|
243
|
-
// slightly break spec here by just simplifying the abstraction for if implementation does not include local political rules for any time zones
|
244
185
|
export const __ecma262_LocalTime = (t: number): number => t;
|
245
186
|
|
246
187
|
// 21.4.1.26 UTC (t)
|
247
188
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-utc-t
|
248
|
-
// slightly break spec here by just simplifying the abstraction for if implementation does not include local political rules for any time zones
|
249
189
|
export const __ecma262_UTC = (t: number): number => {
|
250
190
|
// 1. If t is not finite, return NaN.
|
251
191
|
if (!Number.isFinite(t)) return NaN;
|
252
|
-
|
253
192
|
return t;
|
254
193
|
};
|
255
194
|
|
@@ -260,16 +199,14 @@ export const __ecma262_MakeTime = (hour: number, min: number, sec: number, ms: n
|
|
260
199
|
if (Porffor.fastOr(!Number.isFinite(hour), !Number.isFinite(min), !Number.isFinite(sec), !Number.isFinite(ms))) return NaN;
|
261
200
|
|
262
201
|
// 2. Let h be 𝔽(! ToIntegerOrInfinity(hour)).
|
263
|
-
const h: number = __ecma262_ToIntegerOrInfinity(hour);
|
264
202
|
// 3. Let m be 𝔽(! ToIntegerOrInfinity(min)).
|
265
|
-
const m: number = __ecma262_ToIntegerOrInfinity(min);
|
266
203
|
// 4. Let s be 𝔽(! ToIntegerOrInfinity(sec)).
|
267
|
-
const s: number = __ecma262_ToIntegerOrInfinity(sec);
|
268
204
|
// 5. Let milli be 𝔽(! ToIntegerOrInfinity(ms)).
|
269
|
-
const milli: number = __ecma262_ToIntegerOrInfinity(ms);
|
270
|
-
|
271
205
|
// 6. Return ((h × msPerHour + m × msPerMinute) + s × msPerSecond) + milli.
|
272
|
-
return ((
|
206
|
+
return ((ecma262.ToIntegerOrInfinity(hour) * 3600000
|
207
|
+
+ ecma262.ToIntegerOrInfinity(min) * 60000)
|
208
|
+
+ ecma262.ToIntegerOrInfinity(sec) * 1000)
|
209
|
+
+ ecma262.ToIntegerOrInfinity(ms);
|
273
210
|
};
|
274
211
|
|
275
212
|
// 21.4.1.28 MakeDay (year, month, date)
|
@@ -279,11 +216,11 @@ export const __ecma262_MakeDay = (year: number, month: number, date: number): nu
|
|
279
216
|
if (Porffor.fastOr(!Number.isFinite(year), !Number.isFinite(month), !Number.isFinite(date))) return NaN;
|
280
217
|
|
281
218
|
// 2. Let y be 𝔽(! ToIntegerOrInfinity(year)).
|
282
|
-
const y: number =
|
219
|
+
const y: number = ecma262.ToIntegerOrInfinity(year);
|
283
220
|
// 3. Let m be 𝔽(! ToIntegerOrInfinity(month)).
|
284
|
-
const m: number =
|
221
|
+
const m: number = ecma262.ToIntegerOrInfinity(month);
|
285
222
|
// 4. Let dt be 𝔽(! ToIntegerOrInfinity(date)).
|
286
|
-
const dt: number =
|
223
|
+
const dt: number = ecma262.ToIntegerOrInfinity(date);
|
287
224
|
|
288
225
|
// 5. Let ym be y + 𝔽(floor(ℝ(m) / 12)).
|
289
226
|
let ym: number = y + Math.floor(m / 12);
|
@@ -294,8 +231,8 @@ export const __ecma262_MakeDay = (year: number, month: number, date: number): nu
|
|
294
231
|
// 7. Let mn be 𝔽(ℝ(m) modulo 12).
|
295
232
|
const mn: number = m % 12;
|
296
233
|
|
297
|
-
// 8. Find a finite time value t such that YearFromTime(t) is ym, MonthFromTime(t) is mn, and DateFromTime(t) is 1𝔽;
|
298
|
-
|
234
|
+
// 8. Find a finite time value t such that YearFromTime(t) is ym, MonthFromTime(t) is mn, and DateFromTime(t) is 1𝔽;
|
235
|
+
// but if this is not possible (because some argument is out of range), return NaN.
|
299
236
|
// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
|
300
237
|
if (mn <= 1) ym -= 1;
|
301
238
|
|
@@ -333,7 +270,7 @@ export const __ecma262_MakeFullYear = (year: number): number => {
|
|
333
270
|
if (Number.isNaN(year)) return NaN;
|
334
271
|
|
335
272
|
// 2. Let truncated be ! ToIntegerOrInfinity(year).
|
336
|
-
const truncated: number =
|
273
|
+
const truncated: number = ecma262.ToIntegerOrInfinity(year);
|
337
274
|
|
338
275
|
// 3. If truncated is in the inclusive interval from 0 to 99, return 1900𝔽 + 𝔽(truncated).
|
339
276
|
if (Porffor.fastAnd(truncated >= 0, truncated <= 99)) return 1900 + truncated;
|
@@ -348,12 +285,11 @@ export const __ecma262_MakeFullYear = (year: number): number => {
|
|
348
285
|
export const __ecma262_TimeClip = (time: number): number => {
|
349
286
|
// 1. If time is not finite, return NaN.
|
350
287
|
if (!Number.isFinite(time)) return NaN;
|
351
|
-
|
352
288
|
// 2. If abs(ℝ(time)) > 8.64 × 10**15, return NaN.
|
353
289
|
if (Math.abs(time) > 8.64e+15) return NaN;
|
354
290
|
|
355
291
|
// 3. Return 𝔽(! ToIntegerOrInfinity(time)).
|
356
|
-
return
|
292
|
+
return ecma262.ToIntegerOrInfinity(time);
|
357
293
|
};
|
358
294
|
|
359
295
|
|
@@ -392,27 +328,20 @@ export const __Date_UTC = (year: unknown, month: unknown, date: unknown, hours:
|
|
392
328
|
|
393
329
|
// 7. If ms is present, let milli be ? ToNumber(ms); else let milli be +0𝔽.
|
394
330
|
let milli: number = 0;
|
395
|
-
if (Porffor.type(ms) != Porffor.TYPES.undefined)
|
331
|
+
if (Porffor.type(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
|
396
332
|
|
397
333
|
// 8. Let yr be MakeFullYear(y).
|
398
|
-
const yr: number = __ecma262_MakeFullYear(y);
|
399
|
-
|
400
334
|
// 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))).
|
401
|
-
return __ecma262_TimeClip(__ecma262_MakeDate(
|
335
|
+
return __ecma262_TimeClip(__ecma262_MakeDate(
|
336
|
+
__ecma262_MakeDay(__ecma262_MakeFullYear(y), m, dt),
|
337
|
+
__ecma262_MakeTime(h, min, s, milli)
|
338
|
+
));
|
402
339
|
};
|
403
340
|
|
404
341
|
|
405
342
|
export const __ecma262_WeekDayName = (tv: number): bytestring => {
|
406
343
|
// Name of the entry in Table 62 with the Number WeekDay(tv).
|
407
344
|
// Table 62: Names of days of the week
|
408
|
-
// Number Name
|
409
|
-
// +0𝔽 "Sun"
|
410
|
-
// 1𝔽 "Mon"
|
411
|
-
// 2𝔽 "Tue"
|
412
|
-
// 3𝔽 "Wed"
|
413
|
-
// 4𝔽 "Thu"
|
414
|
-
// 5𝔽 "Fri"
|
415
|
-
// 6𝔽 "Sat"
|
416
345
|
const lut: bytestring = 'SunMonTueWedThuFriSat';
|
417
346
|
const weekday: number = __ecma262_WeekDay(tv);
|
418
347
|
|
@@ -425,26 +354,12 @@ export const __ecma262_WeekDayName = (tv: number): bytestring => {
|
|
425
354
|
Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
|
426
355
|
Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
|
427
356
|
Porffor.wasm.i32.store8(outPtr, Porffor.wasm.i32.load8_u(lutPtr, 0, 4), 0, 4);
|
428
|
-
|
429
357
|
return out;
|
430
358
|
};
|
431
359
|
|
432
360
|
export const __ecma262_MonthName = (tv: number): bytestring => {
|
433
361
|
// Name of the entry in Table 63 with the Number MonthFromTime(tv).
|
434
362
|
// Table 63: Names of months of the year
|
435
|
-
// Number Name
|
436
|
-
// +0𝔽 "Jan"
|
437
|
-
// 1𝔽 "Feb"
|
438
|
-
// 2𝔽 "Mar"
|
439
|
-
// 3𝔽 "Apr"
|
440
|
-
// 4𝔽 "May"
|
441
|
-
// 5𝔽 "Jun"
|
442
|
-
// 6𝔽 "Jul"
|
443
|
-
// 7𝔽 "Aug"
|
444
|
-
// 8𝔽 "Sep"
|
445
|
-
// 9𝔽 "Oct"
|
446
|
-
// 10𝔽 "Nov"
|
447
|
-
// 11𝔽 "Dec"
|
448
363
|
const lut: bytestring = 'JanFebMarAprMayJunJulAugSepOctNovDec';
|
449
364
|
const month: number = __ecma262_MonthFromTime(tv);
|
450
365
|
|
@@ -457,7 +372,6 @@ export const __ecma262_MonthName = (tv: number): bytestring => {
|
|
457
372
|
Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
|
458
373
|
Porffor.wasm.i32.store8(outPtr++, Porffor.wasm.i32.load8_u(lutPtr++, 0, 4), 0, 4);
|
459
374
|
Porffor.wasm.i32.store8(outPtr, Porffor.wasm.i32.load8_u(lutPtr, 0, 4), 0, 4);
|
460
|
-
|
461
375
|
return out;
|
462
376
|
};
|
463
377
|
|
@@ -518,7 +432,6 @@ export const __ecma262_ParseDTSF = (string: bytestring): number => {
|
|
518
432
|
|
519
433
|
let n: number = 0;
|
520
434
|
let nInd: number = 0;
|
521
|
-
let z: boolean = false;
|
522
435
|
|
523
436
|
const len: i32 = string.length;
|
524
437
|
const endPtr: i32 = Porffor.wasm`local.get ${string}` + len;
|
@@ -550,33 +463,15 @@ export const __ecma262_ParseDTSF = (string: bytestring): number => {
|
|
550
463
|
n = 0;
|
551
464
|
nInd++;
|
552
465
|
}
|
553
|
-
|
554
|
-
if (chr == 90) { // Z
|
555
|
-
if (ptr == len) z = true;
|
556
|
-
}
|
557
466
|
}
|
558
467
|
|
559
468
|
h += tzHour;
|
560
469
|
min += tzMin;
|
561
470
|
|
562
|
-
return __ecma262_TimeClip(__ecma262_MakeDate(
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
// "When the time zone offset is absent, date-only forms are interpreted as a UTC time
|
568
|
-
// and date-time forms are interpreted as local time.
|
569
|
-
// This is due to a historical spec error that was not consistent with ISO 8601
|
570
|
-
// but could not be changed due to web compatibility." :))
|
571
|
-
// if (Porffor.fastAnd(
|
572
|
-
// nInd > 3, // not date-only
|
573
|
-
// z == false, // not utc (ending with Z)
|
574
|
-
// nInd < 8, // no time zone offset
|
575
|
-
// )) {
|
576
|
-
// t = __ecma262_UTC(t);
|
577
|
-
// }
|
578
|
-
|
579
|
-
// return t;
|
471
|
+
return __ecma262_TimeClip(__ecma262_MakeDate(
|
472
|
+
__ecma262_MakeDay(y, m, dt),
|
473
|
+
__ecma262_MakeTime(h, min, s, milli)
|
474
|
+
));
|
580
475
|
};
|
581
476
|
|
582
477
|
// RFC 7231 or Date.prototype.toString() parser
|
@@ -665,7 +560,10 @@ export const __ecma262_ParseRFC7231OrToString = (string: bytestring): number =>
|
|
665
560
|
}
|
666
561
|
}
|
667
562
|
|
668
|
-
return __ecma262_TimeClip(__ecma262_MakeDate(
|
563
|
+
return __ecma262_TimeClip(__ecma262_MakeDate(
|
564
|
+
__ecma262_MakeDay(y, m, dt),
|
565
|
+
__ecma262_MakeTime(h, min, s, 0)
|
566
|
+
));
|
669
567
|
};
|
670
568
|
|
671
569
|
// 21.4.3.2 Date.parse (string)
|
@@ -690,9 +588,14 @@ export const __Date_parse = (string: bytestring): number => {
|
|
690
588
|
};
|
691
589
|
|
692
590
|
|
693
|
-
export const __Porffor_date_read = (
|
694
|
-
|
695
|
-
Porffor.wasm.f64.
|
591
|
+
export const __Porffor_date_read = (date: any): number => {
|
592
|
+
if (Porffor.type(date) != Porffor.TYPES.date) throw TypeError('Date prototype methods require this to be a Date object');
|
593
|
+
return Porffor.wasm.f64.load(date, 0, 0);
|
594
|
+
};
|
595
|
+
|
596
|
+
export const __Porffor_date_write = (date: any, val: number) => {
|
597
|
+
if (Porffor.type(date) != Porffor.TYPES.date) throw TypeError('Date prototype methods require this to be a Date object');
|
598
|
+
Porffor.wasm.f64.store(date, val, 0, 0);
|
696
599
|
};
|
697
600
|
|
698
601
|
|
@@ -701,7 +604,7 @@ export const __Porffor_date_write = (ptr: Date, val: number) => {
|
|
701
604
|
|
702
605
|
// 21.4.4.2 Date.prototype.getDate ()
|
703
606
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getdate
|
704
|
-
export const __Date_prototype_getDate = (_this:
|
607
|
+
export const __Date_prototype_getDate = (_this: any) => {
|
705
608
|
// 1. Let dateObject be the this value.
|
706
609
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
707
610
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -716,7 +619,7 @@ export const __Date_prototype_getDate = (_this: Date) => {
|
|
716
619
|
|
717
620
|
// 21.4.4.3 Date.prototype.getDay ()
|
718
621
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getday
|
719
|
-
export const __Date_prototype_getDay = (_this:
|
622
|
+
export const __Date_prototype_getDay = (_this: any) => {
|
720
623
|
// 1. Let dateObject be the this value.
|
721
624
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
722
625
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -731,7 +634,7 @@ export const __Date_prototype_getDay = (_this: Date) => {
|
|
731
634
|
|
732
635
|
// 21.4.4.4 Date.prototype.getFullYear ()
|
733
636
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getfullyear
|
734
|
-
export const __Date_prototype_getFullYear = (_this:
|
637
|
+
export const __Date_prototype_getFullYear = (_this: any) => {
|
735
638
|
// 1. Let dateObject be the this value.
|
736
639
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
737
640
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -746,7 +649,7 @@ export const __Date_prototype_getFullYear = (_this: Date) => {
|
|
746
649
|
|
747
650
|
// 21.4.4.5 Date.prototype.getHours ()
|
748
651
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.gethours
|
749
|
-
export const __Date_prototype_getHours = (_this:
|
652
|
+
export const __Date_prototype_getHours = (_this: any) => {
|
750
653
|
// 1. Let dateObject be the this value.
|
751
654
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
752
655
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -761,7 +664,7 @@ export const __Date_prototype_getHours = (_this: Date) => {
|
|
761
664
|
|
762
665
|
// 21.4.4.6 Date.prototype.getMilliseconds ()
|
763
666
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getmilliseconds
|
764
|
-
export const __Date_prototype_getMilliseconds = (_this:
|
667
|
+
export const __Date_prototype_getMilliseconds = (_this: any) => {
|
765
668
|
// 1. Let dateObject be the this value.
|
766
669
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
767
670
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -776,7 +679,7 @@ export const __Date_prototype_getMilliseconds = (_this: Date) => {
|
|
776
679
|
|
777
680
|
// 21.4.4.7 Date.prototype.getMinutes ()
|
778
681
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getminutes
|
779
|
-
export const __Date_prototype_getMinutes = (_this:
|
682
|
+
export const __Date_prototype_getMinutes = (_this: any) => {
|
780
683
|
// 1. Let dateObject be the this value.
|
781
684
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
782
685
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -791,7 +694,7 @@ export const __Date_prototype_getMinutes = (_this: Date) => {
|
|
791
694
|
|
792
695
|
// 21.4.4.8 Date.prototype.getMonth ()
|
793
696
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getmonth
|
794
|
-
export const __Date_prototype_getMonth = (_this:
|
697
|
+
export const __Date_prototype_getMonth = (_this: any) => {
|
795
698
|
// 1. Let dateObject be the this value.
|
796
699
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
797
700
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -806,7 +709,7 @@ export const __Date_prototype_getMonth = (_this: Date) => {
|
|
806
709
|
|
807
710
|
// 21.4.4.9 Date.prototype.getSeconds ()
|
808
711
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getseconds
|
809
|
-
export const __Date_prototype_getSeconds = (_this:
|
712
|
+
export const __Date_prototype_getSeconds = (_this: any) => {
|
810
713
|
// 1. Let dateObject be the this value.
|
811
714
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
812
715
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -821,7 +724,7 @@ export const __Date_prototype_getSeconds = (_this: Date) => {
|
|
821
724
|
|
822
725
|
// 21.4.4.10 Date.prototype.getTime ()
|
823
726
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.gettime
|
824
|
-
export const __Date_prototype_getTime = (_this:
|
727
|
+
export const __Date_prototype_getTime = (_this: any) => {
|
825
728
|
// 1. Let dateObject be the this value.
|
826
729
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
827
730
|
// 3. Return dateObject.[[DateValue]].
|
@@ -830,7 +733,7 @@ export const __Date_prototype_getTime = (_this: Date) => {
|
|
830
733
|
|
831
734
|
// 21.4.4.11 Date.prototype.getTimezoneOffset ()
|
832
735
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.gettimezoneoffset
|
833
|
-
export const __Date_prototype_getTimezoneOffset = (_this:
|
736
|
+
export const __Date_prototype_getTimezoneOffset = (_this: any) => {
|
834
737
|
// 1. Let dateObject be the this value.
|
835
738
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
836
739
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -845,7 +748,7 @@ export const __Date_prototype_getTimezoneOffset = (_this: Date) => {
|
|
845
748
|
|
846
749
|
// 21.4.4.12 Date.prototype.getUTCDate ()
|
847
750
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getutcdate
|
848
|
-
export const __Date_prototype_getUTCDate = (_this:
|
751
|
+
export const __Date_prototype_getUTCDate = (_this: any) => {
|
849
752
|
// 1. Let dateObject be the this value.
|
850
753
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
851
754
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -860,7 +763,7 @@ export const __Date_prototype_getUTCDate = (_this: Date) => {
|
|
860
763
|
|
861
764
|
// 21.4.4.13 Date.prototype.getUTCDay ()
|
862
765
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getutcday
|
863
|
-
export const __Date_prototype_getUTCDay = (_this:
|
766
|
+
export const __Date_prototype_getUTCDay = (_this: any) => {
|
864
767
|
// 1. Let dateObject be the this value.
|
865
768
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
866
769
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -875,7 +778,7 @@ export const __Date_prototype_getUTCDay = (_this: Date) => {
|
|
875
778
|
|
876
779
|
// 21.4.4.14 Date.prototype.getUTCFullYear ()
|
877
780
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getutcfullyear
|
878
|
-
export const __Date_prototype_getUTCFullYear = (_this:
|
781
|
+
export const __Date_prototype_getUTCFullYear = (_this: any) => {
|
879
782
|
// 1. Let dateObject be the this value.
|
880
783
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
881
784
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -890,7 +793,7 @@ export const __Date_prototype_getUTCFullYear = (_this: Date) => {
|
|
890
793
|
|
891
794
|
// 21.4.4.15 Date.prototype.getUTCHours ()
|
892
795
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getutchours
|
893
|
-
export const __Date_prototype_getUTCHours = (_this:
|
796
|
+
export const __Date_prototype_getUTCHours = (_this: any) => {
|
894
797
|
// 1. Let dateObject be the this value.
|
895
798
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
896
799
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -905,7 +808,7 @@ export const __Date_prototype_getUTCHours = (_this: Date) => {
|
|
905
808
|
|
906
809
|
// 21.4.4.16 Date.prototype.getUTCMilliseconds ()
|
907
810
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getutcmilliseconds
|
908
|
-
export const __Date_prototype_getUTCMilliseconds = (_this:
|
811
|
+
export const __Date_prototype_getUTCMilliseconds = (_this: any) => {
|
909
812
|
// 1. Let dateObject be the this value.
|
910
813
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
911
814
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -920,7 +823,7 @@ export const __Date_prototype_getUTCMilliseconds = (_this: Date) => {
|
|
920
823
|
|
921
824
|
// 21.4.4.17 Date.prototype.getUTCMinutes ()
|
922
825
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getutcminutes
|
923
|
-
export const __Date_prototype_getUTCMinutes = (_this:
|
826
|
+
export const __Date_prototype_getUTCMinutes = (_this: any) => {
|
924
827
|
// 1. Let dateObject be the this value.
|
925
828
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
926
829
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -935,7 +838,7 @@ export const __Date_prototype_getUTCMinutes = (_this: Date) => {
|
|
935
838
|
|
936
839
|
// 21.4.4.18 Date.prototype.getUTCMonth ()
|
937
840
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getutcmonth
|
938
|
-
export const __Date_prototype_getUTCMonth = (_this:
|
841
|
+
export const __Date_prototype_getUTCMonth = (_this: any) => {
|
939
842
|
// 1. Let dateObject be the this value.
|
940
843
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
941
844
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -950,7 +853,7 @@ export const __Date_prototype_getUTCMonth = (_this: Date) => {
|
|
950
853
|
|
951
854
|
// 21.4.4.19 Date.prototype.getUTCSeconds ()
|
952
855
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getutcseconds
|
953
|
-
export const __Date_prototype_getUTCSeconds = (_this:
|
856
|
+
export const __Date_prototype_getUTCSeconds = (_this: any) => {
|
954
857
|
// 1. Let dateObject be the this value.
|
955
858
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
956
859
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -966,7 +869,7 @@ export const __Date_prototype_getUTCSeconds = (_this: Date) => {
|
|
966
869
|
|
967
870
|
// 21.4.4.20 Date.prototype.setDate (date)
|
968
871
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setdate
|
969
|
-
export const __Date_prototype_setDate = (_this:
|
872
|
+
export const __Date_prototype_setDate = (_this: any, date: any) => {
|
970
873
|
// 1. Let dateObject be the this value.
|
971
874
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
972
875
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -996,7 +899,7 @@ export const __Date_prototype_setDate = (_this: Date, date: any) => {
|
|
996
899
|
|
997
900
|
// 21.4.4.21 Date.prototype.setFullYear (year [, month [, date ]])
|
998
901
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setfullyear
|
999
|
-
export const __Date_prototype_setFullYear = (_this:
|
902
|
+
export const __Date_prototype_setFullYear = (_this: any, year: any, month: any, date: any) => {
|
1000
903
|
// 1. Let dateObject be the this value.
|
1001
904
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1002
905
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1034,7 +937,7 @@ export const __Date_prototype_setFullYear = (_this: Date, year: any, month: any,
|
|
1034
937
|
|
1035
938
|
// 21.4.4.22 Date.prototype.setHours (hour [, min [, sec [, ms ]]])
|
1036
939
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.sethours
|
1037
|
-
export const __Date_prototype_setHours = (_this:
|
940
|
+
export const __Date_prototype_setHours = (_this: any, hour: any, min: any, sec: any, ms: any) => {
|
1038
941
|
// 1. Let dateObject be the this value.
|
1039
942
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1040
943
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1084,7 +987,7 @@ export const __Date_prototype_setHours = (_this: Date, hour: any, min: any, sec:
|
|
1084
987
|
|
1085
988
|
// 21.4.4.23 Date.prototype.setMilliseconds (ms)
|
1086
989
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setmilliseconds
|
1087
|
-
export const __Date_prototype_setMilliseconds = (_this:
|
990
|
+
export const __Date_prototype_setMilliseconds = (_this: any, ms: any) => {
|
1088
991
|
// 1. Let dateObject be the this value.
|
1089
992
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1090
993
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1115,7 +1018,7 @@ export const __Date_prototype_setMilliseconds = (_this: Date, ms: any) => {
|
|
1115
1018
|
|
1116
1019
|
// 21.4.4.24 Date.prototype.setMinutes (min [, sec [, ms ]])
|
1117
1020
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setminutes
|
1118
|
-
export const __Date_prototype_setMinutes = (_this:
|
1021
|
+
export const __Date_prototype_setMinutes = (_this: any, min: any, sec: any, ms: any) => {
|
1119
1022
|
// 1. Let dateObject be the this value.
|
1120
1023
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1121
1024
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1159,7 +1062,7 @@ export const __Date_prototype_setMinutes = (_this: Date, min: any, sec: any, ms:
|
|
1159
1062
|
|
1160
1063
|
// 21.4.4.25 Date.prototype.setMonth (month [, date ])
|
1161
1064
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setmonth
|
1162
|
-
export const __Date_prototype_setMonth = (_this:
|
1065
|
+
export const __Date_prototype_setMonth = (_this: any, month: any, date: any) => {
|
1163
1066
|
// 1. Let dateObject be the this value.
|
1164
1067
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1165
1068
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1197,7 +1100,7 @@ export const __Date_prototype_setMonth = (_this: Date, month: any, date: any) =>
|
|
1197
1100
|
|
1198
1101
|
// 21.4.4.26 Date.prototype.setSeconds (sec [, ms ])
|
1199
1102
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setseconds
|
1200
|
-
export const __Date_prototype_setSeconds = (_this:
|
1103
|
+
export const __Date_prototype_setSeconds = (_this: any, sec: any, ms: any) => {
|
1201
1104
|
// 1. Let dateObject be the this value.
|
1202
1105
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1203
1106
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1207,7 +1110,6 @@ export const __Date_prototype_setSeconds = (_this: Date, sec: any, ms: any) => {
|
|
1207
1110
|
const s: number = ecma262.ToNumber(sec);
|
1208
1111
|
|
1209
1112
|
// we reorder the spec steps in this func for easier arg handling
|
1210
|
-
|
1211
1113
|
// 6. If t is NaN, return NaN.
|
1212
1114
|
if (Number.isNaN(t)) return NaN;
|
1213
1115
|
|
@@ -1236,7 +1138,7 @@ export const __Date_prototype_setSeconds = (_this: Date, sec: any, ms: any) => {
|
|
1236
1138
|
|
1237
1139
|
// 21.4.4.27 Date.prototype.setTime (time)
|
1238
1140
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.settime
|
1239
|
-
export const __Date_prototype_setTime = (_this:
|
1141
|
+
export const __Date_prototype_setTime = (_this: any, time: any) => {
|
1240
1142
|
// 1. Let dateObject be the this value.
|
1241
1143
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1242
1144
|
// 3. Let t be ? ToNumber(time).
|
@@ -1254,7 +1156,7 @@ export const __Date_prototype_setTime = (_this: Date, time: any) => {
|
|
1254
1156
|
|
1255
1157
|
// 21.4.4.28 Date.prototype.setUTCDate (date)
|
1256
1158
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setutcdate
|
1257
|
-
export const __Date_prototype_setUTCDate = (_this:
|
1159
|
+
export const __Date_prototype_setUTCDate = (_this: any, date: any) => {
|
1258
1160
|
// 1. Let dateObject be the this value.
|
1259
1161
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1260
1162
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1281,7 +1183,7 @@ export const __Date_prototype_setUTCDate = (_this: Date, date: any) => {
|
|
1281
1183
|
|
1282
1184
|
// 21.4.4.29 Date.prototype.setUTCFullYear (year [, month [, date ]])
|
1283
1185
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setutcfullyear
|
1284
|
-
export const __Date_prototype_setUTCFullYear = (_this:
|
1186
|
+
export const __Date_prototype_setUTCFullYear = (_this: any, year: any, month: any, date: any) => {
|
1285
1187
|
// 1. Let dateObject be the this value.
|
1286
1188
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1287
1189
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1318,7 +1220,7 @@ export const __Date_prototype_setUTCFullYear = (_this: Date, year: any, month: a
|
|
1318
1220
|
|
1319
1221
|
// 21.4.4.30 Date.prototype.setUTCHours (hour [, min [, sec [, ms ]]])
|
1320
1222
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setutchours
|
1321
|
-
export const __Date_prototype_setUTCHours = (_this:
|
1223
|
+
export const __Date_prototype_setUTCHours = (_this: any, hour: any, min: any, sec: any, ms: any) => {
|
1322
1224
|
// 1. Let dateObject be the this value.
|
1323
1225
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1324
1226
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1365,7 +1267,7 @@ export const __Date_prototype_setUTCHours = (_this: Date, hour: any, min: any, s
|
|
1365
1267
|
|
1366
1268
|
// 21.4.4.31 Date.prototype.setUTCMilliseconds (ms)
|
1367
1269
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setutcmilliseconds
|
1368
|
-
export const __Date_prototype_setUTCMilliseconds = (_this:
|
1270
|
+
export const __Date_prototype_setUTCMilliseconds = (_this: any, ms: any) => {
|
1369
1271
|
// 1. Let dateObject be the this value.
|
1370
1272
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1371
1273
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1393,7 +1295,7 @@ export const __Date_prototype_setUTCMilliseconds = (_this: Date, ms: any) => {
|
|
1393
1295
|
|
1394
1296
|
// 21.4.4.32 Date.prototype.setUTCMinutes (min [, sec [, ms ]])
|
1395
1297
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setutcminutes
|
1396
|
-
export const __Date_prototype_setUTCMinutes = (_this:
|
1298
|
+
export const __Date_prototype_setUTCMinutes = (_this: any, min: any, sec: any, ms: any) => {
|
1397
1299
|
// 1. Let dateObject be the this value.
|
1398
1300
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1399
1301
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1434,7 +1336,7 @@ export const __Date_prototype_setUTCMinutes = (_this: Date, min: any, sec: any,
|
|
1434
1336
|
|
1435
1337
|
// 21.4.4.33 Date.prototype.setUTCMonth (month [, date ])
|
1436
1338
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setutcmonth
|
1437
|
-
export const __Date_prototype_setUTCMonth = (_this:
|
1339
|
+
export const __Date_prototype_setUTCMonth = (_this: any, month: any, date: any) => {
|
1438
1340
|
// 1. Let dateObject be the this value.
|
1439
1341
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1440
1342
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1469,7 +1371,7 @@ export const __Date_prototype_setUTCMonth = (_this: Date, month: any, date: any)
|
|
1469
1371
|
|
1470
1372
|
// 21.4.4.34 Date.prototype.setUTCSeconds (sec [, ms ])
|
1471
1373
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.setutcseconds
|
1472
|
-
export const __Date_prototype_setUTCSeconds = (_this:
|
1374
|
+
export const __Date_prototype_setUTCSeconds = (_this: any, sec: any, ms: any) => {
|
1473
1375
|
// 1. Let dateObject be the this value.
|
1474
1376
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1475
1377
|
// 3. Let t be dateObject.[[DateValue]].
|
@@ -1478,16 +1380,15 @@ export const __Date_prototype_setUTCSeconds = (_this: Date, sec: any, ms: any) =
|
|
1478
1380
|
// 4. Let s be ? ToNumber(sec).
|
1479
1381
|
const s: number = ecma262.ToNumber(sec);
|
1480
1382
|
|
1481
|
-
// we reorder the spec steps in this func for easier arg handling
|
1482
|
-
|
1483
|
-
// 6. If t is NaN, return NaN.
|
1484
|
-
if (Number.isNaN(t)) return NaN;
|
1485
|
-
|
1486
1383
|
// 5. If ms is present, let milli be ? ToNumber(ms).
|
1487
1384
|
let milli: number;
|
1488
1385
|
if (Porffor.type(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
|
1489
|
-
|
1490
|
-
|
1386
|
+
|
1387
|
+
// 6. If t is NaN, return NaN.
|
1388
|
+
if (Number.isNaN(t)) return NaN;
|
1389
|
+
|
1390
|
+
// 7. If ms is not present, let milli be msFromTime(t).
|
1391
|
+
if (Porffor.type(ms) == Porffor.TYPES.undefined) milli = __ecma262_msFromTime(t);
|
1491
1392
|
|
1492
1393
|
// 8. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, milli)).
|
1493
1394
|
const date: number = __ecma262_MakeDate(__ecma262_Day(t), __ecma262_MakeTime(__ecma262_HourFromTime(t), __ecma262_MinFromTime(t), s, milli));
|
@@ -1616,13 +1517,12 @@ export const __ecma262_ToUTCDTSF = (t: number): bytestring => {
|
|
1616
1517
|
// 3 digit millisecond
|
1617
1518
|
__Porffor_bytestring_appendPadNum(out, __ecma262_msFromTime(t), 3);
|
1618
1519
|
__Porffor_bytestring_appendChar(out, 90); // Z
|
1619
|
-
|
1620
1520
|
return out;
|
1621
1521
|
};
|
1622
1522
|
|
1623
1523
|
// 21.4.4.36 Date.prototype.toISOString ()
|
1624
1524
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.toisostring
|
1625
|
-
export const __Date_prototype_toISOString = (_this:
|
1525
|
+
export const __Date_prototype_toISOString = (_this: any) => {
|
1626
1526
|
// 1. Let dateObject be the this value.
|
1627
1527
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1628
1528
|
// 3. Let tv be dateObject.[[DateValue]].
|
@@ -1644,7 +1544,7 @@ export const __Date_prototype_toISOString = (_this: Date) => {
|
|
1644
1544
|
|
1645
1545
|
// 21.4.4.37 Date.prototype.toJSON (key)
|
1646
1546
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.tojson
|
1647
|
-
export const __Date_prototype_toJSON = (_this:
|
1547
|
+
export const __Date_prototype_toJSON = (_this: any, key: any) => {
|
1648
1548
|
// 1. Let O be ? ToObject(this value).
|
1649
1549
|
// 2. Let tv be ? ToPrimitive(O, number).
|
1650
1550
|
// todo: use generic ecma262.ToNumber() once it supports Date
|
@@ -1686,7 +1586,6 @@ export const __ecma262_TimeString = (tv: number): bytestring => {
|
|
1686
1586
|
__Porffor_bytestring_appendChar(out, 71); // 'G'
|
1687
1587
|
__Porffor_bytestring_appendChar(out, 77); // 'M'
|
1688
1588
|
__Porffor_bytestring_appendChar(out, 84); // 'T'
|
1689
|
-
|
1690
1589
|
return out;
|
1691
1590
|
};
|
1692
1591
|
|
@@ -1727,7 +1626,6 @@ export const __ecma262_DateString = (tv: number): bytestring => {
|
|
1727
1626
|
// year
|
1728
1627
|
if (yv < 0) __Porffor_bytestring_appendChar(out, 45); // sign
|
1729
1628
|
__Porffor_bytestring_appendPadNum(out, yv, 4);
|
1730
|
-
|
1731
1629
|
return out;
|
1732
1630
|
};
|
1733
1631
|
|
@@ -1755,13 +1653,12 @@ export const __ecma262_ToDateString = (tv: number) => {
|
|
1755
1653
|
__Porffor_bytestring_appendStr(out, __ecma262_TimeString(t));
|
1756
1654
|
|
1757
1655
|
__Porffor_bytestring_appendStr(out, __ecma262_TimeZoneString(tv));
|
1758
|
-
|
1759
1656
|
return out;
|
1760
1657
|
};
|
1761
1658
|
|
1762
1659
|
// 21.4.4.41 Date.prototype.toString ()
|
1763
1660
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.tostring
|
1764
|
-
export const __Date_prototype_toString = (_this:
|
1661
|
+
export const __Date_prototype_toString = (_this: any) => {
|
1765
1662
|
// 1. Let dateObject be the this value.
|
1766
1663
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1767
1664
|
// 3. Let tv be dateObject.[[DateValue]].
|
@@ -1773,7 +1670,7 @@ export const __Date_prototype_toString = (_this: Date) => {
|
|
1773
1670
|
|
1774
1671
|
// 21.4.4.42 Date.prototype.toTimeString ()
|
1775
1672
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.totimestring
|
1776
|
-
export const __Date_prototype_toTimeString = (_this:
|
1673
|
+
export const __Date_prototype_toTimeString = (_this: any) => {
|
1777
1674
|
// 1. Let dateObject be the this value.
|
1778
1675
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1779
1676
|
// 3. Let tv be dateObject.[[DateValue]].
|
@@ -1789,14 +1686,13 @@ export const __Date_prototype_toTimeString = (_this: Date) => {
|
|
1789
1686
|
const out: bytestring = Porffor.allocateBytes(27);
|
1790
1687
|
__Porffor_bytestring_appendStr(out, __ecma262_TimeString(t));
|
1791
1688
|
__Porffor_bytestring_appendStr(out, __ecma262_TimeZoneString(tv));
|
1792
|
-
|
1793
1689
|
return out;
|
1794
1690
|
};
|
1795
1691
|
|
1796
1692
|
|
1797
1693
|
// 21.4.4.35 Date.prototype.toDateString ()
|
1798
1694
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.todatestring
|
1799
|
-
export const __Date_prototype_toDateString = (_this:
|
1695
|
+
export const __Date_prototype_toDateString = (_this: any) => {
|
1800
1696
|
// 1. Let dateObject be the this value.
|
1801
1697
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1802
1698
|
// 3. Let tv be dateObject.[[DateValue]].
|
@@ -1814,7 +1710,7 @@ export const __Date_prototype_toDateString = (_this: Date) => {
|
|
1814
1710
|
|
1815
1711
|
// 21.4.4.43 Date.prototype.toUTCString ()
|
1816
1712
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.toutcstring
|
1817
|
-
export const __Date_prototype_toUTCString = (_this:
|
1713
|
+
export const __Date_prototype_toUTCString = (_this: any) => {
|
1818
1714
|
// 1. Let dateObject be the this value.
|
1819
1715
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1820
1716
|
// 3. Let tv be dateObject.[[DateValue]].
|
@@ -1861,31 +1757,30 @@ export const __Date_prototype_toUTCString = (_this: Date) => {
|
|
1861
1757
|
|
1862
1758
|
__Porffor_bytestring_appendChar(out, 32); // ' '
|
1863
1759
|
__Porffor_bytestring_appendStr(out, __ecma262_TimeString(tv));
|
1864
|
-
|
1865
1760
|
return out;
|
1866
1761
|
};
|
1867
1762
|
|
1868
1763
|
// 21.4.4.38 Date.prototype.toLocaleDateString ([ reserved1 [, reserved2 ]])
|
1869
1764
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.tolocaledatestring
|
1870
|
-
export const __Date_prototype_toLocaleDateString = (_this:
|
1765
|
+
export const __Date_prototype_toLocaleDateString = (_this: any, reserved1: any, reserved2: any) => {
|
1871
1766
|
return __Date_prototype_toDateString(_this);
|
1872
1767
|
};
|
1873
1768
|
|
1874
1769
|
// 21.4.4.39 Date.prototype.toLocaleString ([ reserved1 [, reserved2 ]])
|
1875
1770
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.tolocalestring
|
1876
|
-
export const __Date_prototype_toLocaleString = (_this:
|
1771
|
+
export const __Date_prototype_toLocaleString = (_this: any, reserved1: any, reserved2: any) => {
|
1877
1772
|
return __Date_prototype_toString(_this);
|
1878
1773
|
};
|
1879
1774
|
|
1880
1775
|
// 21.4.4.40 Date.prototype.toLocaleTimeString ([ reserved1 [, reserved2 ]])
|
1881
1776
|
// https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.tolocaletimestring
|
1882
|
-
export const __Date_prototype_toLocaleTimeString = (_this:
|
1777
|
+
export const __Date_prototype_toLocaleTimeString = (_this: any, reserved1: any, reserved2: any) => {
|
1883
1778
|
return __Date_prototype_toTimeString(_this);
|
1884
1779
|
};
|
1885
1780
|
|
1886
1781
|
// 21.4.4.44 Date.prototype.valueOf ()
|
1887
1782
|
// https://tc39.es/ecma262/#sec-date.prototype.valueof
|
1888
|
-
export const __Date_prototype_valueOf = (_this:
|
1783
|
+
export const __Date_prototype_valueOf = (_this: any) => {
|
1889
1784
|
// 1. Let dateObject be the this value.
|
1890
1785
|
// 2. Perform ? RequireInternalSlot(dateObject, [[DateValue]]).
|
1891
1786
|
// 3. Return dateObject.[[DateValue]].
|