MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / toISOString

Function toISOString

tests/test_code/js/moment/moment.js:3911–3939  ·  view source on GitHub ↗
(keepOffset)

Source from the content-addressed store, hash-verified

3909 }
3910
3911 function toISOString(keepOffset) {
3912 if (!this.isValid()) {
3913 return null;
3914 }
3915 var utc = keepOffset !== true,
3916 m = utc ? this.clone().utc() : this;
3917 if (m.year() < 0 || m.year() > 9999) {
3918 return formatMoment(
3919 m,
3920 utc
3921 ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
3922 : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
3923 );
3924 }
3925 if (isFunction(Date.prototype.toISOString)) {
3926 // native implementation is ~50x faster, use it when we can
3927 if (utc) {
3928 return this.toDate().toISOString();
3929 } else {
3930 return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
3931 .toISOString()
3932 .replace('Z', formatMoment(m, 'Z'));
3933 }
3934 }
3935 return formatMoment(
3936 m,
3937 utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
3938 );
3939 }
3940
3941 /**
3942 * Return a human readable representation of a moment that can

Callers

nothing calls this directly

Calls 2

formatMomentFunction · 0.85
isFunctionFunction · 0.85

Tested by

no test coverage detected