diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js b/js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js new file mode 100644 index 0000000000..9dffe30587 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js @@ -0,0 +1,41 @@ +// Copyright (C) 2018 Andrew Paprocki. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.parse +description: > + Date.parse return value is limited to specified time value maximum range +info: | + Date.parse ( string ) + + parse interprets the resulting String as a date and time; it returns a + Number, the UTC time value corresponding to the date and time. + + A Date object contains a Number indicating a particular instant in time to + within a millisecond. Such a Number is called a time value. + + The actual range of times supported by ECMAScript Date objects is slightly + smaller: exactly -100,000,000 days to 100,000,000 days measured relative to + midnight at the beginning of 01 January, 1970 UTC. This gives a range of + 8,640,000,000,000,000 milliseconds to either side of 01 January, 1970 UTC. +---*/ + +const minDateStr = "-271821-04-20T00:00:00.000Z"; +const minDate = new Date(-8640000000000000); + +assert.sameValue(minDate.toISOString(), minDateStr, "minDateStr"); +assert.sameValue(Date.parse(minDateStr), minDate.valueOf(), "parse minDateStr"); + +const maxDateStr = "+275760-09-13T00:00:00.000Z"; +const maxDate = new Date(8640000000000000); + +assert.sameValue(maxDate.toISOString(), maxDateStr, "maxDateStr"); +assert.sameValue(Date.parse(maxDateStr), maxDate.valueOf(), "parse maxDateStr"); + +const belowRange = "-271821-04-19T23:59:59.999Z"; +const aboveRange = "+275760-09-13T00:00:00.001Z"; + +assert.sameValue(Date.parse(belowRange), NaN, "parse below minimum time value"); +assert.sameValue(Date.parse(aboveRange), NaN, "parse above maximum time value"); + +reportCompare(0, 0); |