rhino1.7.7.testsrc.doctests.date.toisostring.doctest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rhino Show documentation
Show all versions of rhino Show documentation
Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically
embedded into Java applications to provide scripting to end users.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
js> load('testsrc/doctests/util.js');
js> Date.prototype.toISOString;
function toISOString() { [native code for Date.toISOString, arity=0] }
js> expectError(function() {
> new Date(Infinity).toISOString()
> }, RangeError);
js> new Date(0).toISOString()
1970-01-01T00:00:00.000Z
js> var isoFormat = /(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d).(\d\d\d)Z/;
js> var now = new Date();
js> var matches = isoFormat.exec(now.toISOString());
js> matches[0] === now.toISOString()
true
js> matches[1] == now.getUTCFullYear()
true
js> matches[2] == now.getUTCMonth()+1
true
js> matches[3] == now.getUTCDate()
true
js> matches[4] == now.getUTCHours()
true
js> matches[5] == now.getUTCMinutes()
true
js> matches[6] == now.getUTCSeconds()
true
js> matches[7] == now.getUTCMilliseconds()
true
© 2015 - 2024 Weber Informatics LLC | Privacy Policy