import { configFromObject } from './from-object';
function createFromConfig (config) {
+ var res = new Moment(checkOverflow(prepareConfig(config)));
+ if (res._nextDay) {
+ // Adding is smart enough around DST
+ res.add(1, 'd');
+ res._nextDay = undefined;
+ }
+
+ return res;
+}
+
+export function prepareConfig (config) {
var input = config._i,
- format = config._f,
- res;
+ format = config._f;
config._locale = config._locale || getLocale(config._l);
configFromInput(config);
}
- res = new Moment(checkOverflow(config));
- if (res._nextDay) {
- // Adding is smart enough around DST
- res.add(1, 'd');
- res._nextDay = undefined;
- }
-
- return res;
+ return config;
}
function configFromInput(config) {
import zeroFill from '../utils/zero-fill';
import { createDuration } from '../duration/create';
import { addSubtract } from '../moment/add-subtract';
-import { isMoment } from '../moment/constructor';
+import { isMoment, copyConfig } from '../moment/constructor';
import { addFormatToken } from '../format/format';
import { addRegexToken, matchOffset } from '../parse/regex';
import { addParseToken } from '../parse/token';
import { createLocal } from '../create/local';
+import { prepareConfig } from '../create/from-anything';
import { createUTC } from '../create/utc';
import isDate from '../utils/is-date';
import toInt from '../utils/to-int';
}
export function isDaylightSavingTimeShifted () {
- if (this._a) {
- var other = this._isUTC ? createUTC(this._a) : createLocal(this._a);
- return this.isValid() && compareArrays(this._a, other.toArray()) > 0;
+ if (typeof this._isDSTShifted !== 'undefined') {
+ return this._isDSTShifted;
}
- return false;
+ var c = {};
+
+ copyConfig(c, this);
+ c = prepareConfig(c);
+
+ if (c._a) {
+ var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
+ this._isDSTShifted = this.isValid() &&
+ compareArrays(c._a, other.toArray()) > 0;
+ } else {
+ this._isDSTShifted = false;
+ }
+
+ return this._isDSTShifted;
}
export function isLocal () {