MCPcopy
hub / github.com/tdewolff/minify / getSetOffset

Function getSetOffset

_benchmarks/sample_moment.js:3381–3422  ·  view source on GitHub ↗
(input, keepLocalTime, keepMinutes)

Source from the content-addressed store, hash-verified

3379 // _changeInProgress == true case, then we have to adjust, because
3380 // there is no such time in the given timezone.
3381 function getSetOffset(input, keepLocalTime, keepMinutes) {
3382 var offset = this._offset || 0,
3383 localAdjust;
3384 if (!this.isValid()) {
3385 return input != null ? this : NaN;
3386 }
3387 if (input != null) {
3388 if (typeof input === 'string') {
3389 input = offsetFromString(matchShortOffset, input);
3390 if (input === null) {
3391 return this;
3392 }
3393 } else if (Math.abs(input) < 16 && !keepMinutes) {
3394 input = input * 60;
3395 }
3396 if (!this._isUTC && keepLocalTime) {
3397 localAdjust = getDateOffset(this);
3398 }
3399 this._offset = input;
3400 this._isUTC = true;
3401 if (localAdjust != null) {
3402 this.add(localAdjust, 'm');
3403 }
3404 if (offset !== input) {
3405 if (!keepLocalTime || this._changeInProgress) {
3406 addSubtract(
3407 this,
3408 createDuration(input - offset, 'm'),
3409 1,
3410 false
3411 );
3412 } else if (!this._changeInProgress) {
3413 this._changeInProgress = true;
3414 hooks.updateOffset(this, true);
3415 this._changeInProgress = null;
3416 }
3417 }
3418 return this;
3419 } else {
3420 return this._isUTC ? offset : getDateOffset(this);
3421 }
3422 }
3423
3424 function getSetZone(input, keepLocalTime) {
3425 if (input != null) {

Callers

nothing calls this directly

Calls 4

offsetFromStringFunction · 0.85
getDateOffsetFunction · 0.85
addSubtractFunction · 0.85
createDurationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…