--- /dev/null
+# creation
+
+createMoment({
+ input,
+ locale,
+ format,
+ strict, # dfl - yes?
+ timeZone, # dfl - local
+ # localHandling, [OVERLAP_FIRST|OVERLAP_SECOND|OVERLAP_THROW] + [HOLE_FWD|HOLE_BWD|HOLE_THROW]
+})
+
+quickCreate({
+ date,
+ locale,
+ timeZone
+})
+
+
+
+
+* createLocal (local)
+* createLocalOrUTC (from-anything) -> just puts inp data in config object
+* createFromConfig (from-anything)
+* prepareConfig (from-anything)
+ --> from moment
+ --> from date
+ --> from str+array configFromStringAndArray
+ --> from str+fmt configFromStringAndFormat
+ --> from input (str only) configFromInput
+
+# am/pm bug 297 -- should be able to skip am/pm ?
+# array of formats --> there won't be any leftovers, so rethink strict with arrays
+ ---> define strictness with flags and make it configurable?
+# X (unix) parses also parts, we need to make X.S, X.SS and X.SSS separate tokens
+# 'str Z' is not valid ISO, 'strZ' is
+# what about all the locale issues related to strict parsing
--- /dev/null
+import { createCollect } from './from-anything';
+import { localTimeZone } from '../timezone/local';
+import { fixedTimeZoneForOffset } from '../timezone/fixed-offset';
+
+export function createUTC (input, format, locale, strict) {
+ return createCollect(input, format, locale, strict, fixedTimeZoneForOffset(0));
+}
+
+export function createFixedOffset (offset) {
+ // maybe parse offset
+ return function (input, format, locale, strict) {
+ return createCollect(input, format, locale, strict, fixedTimeZoneForOffset(offset));
+ }
+}
+
+// TODO(Iskren): Recheck all internal uses and take into account that it
+// WON'T copy the zone any more
+export function createLocal (input, format, locale, strict) {
+ return createCollect(input, format, locale, strict, localTimeZone);
+}
+
+export function createZoned (tz) {
+ return function (input, format, locale, strict) {
+ return createCollect(input, format, locale, strict, tz);
+ }
+}
var res = new Moment(checkOverflow(prepareConfig(config)));
// Prevent infinite loop in case updateOffset creates new moment objects.
- if (updateInProgress === false) {
- updateInProgress = true;
- res = hooks.updateOffset(res);
- updateInProgress = false;
- }
+ // if (updateInProgress === false) {
+ // updateInProgress = true;
+ // res = hooks.updateOffset(res);
+ // updateInProgress = false;
+ // }
if (res._nextDay) {
// Adding is smart enough around DST
config._i = input = config._locale.preparse(input);
}
- if (isMoment(input)) {
+ if (input._d != null || input._l != null && input._isAMomentObject !== true) {
+ // If it looks like a moment, but isn't
+ throw new Error("No uninitialized config should ever reach this place");
+ } else if (isMoment(input)) {
+ // TODO(iskren): This is wrong, we create moment twice, this is
+ // supposed to return ready config
+ //
+ // TODOv3(iskren): config._i could be just config in-progress? I don't
+ // think this should be allowed -- find all places by removing
+ // isAMomentObject from config and setting it in the constructor.
return new Moment(checkOverflow(input));
} else if (isDate(input)) {
config._d = input;
}
}
-export function createLocalOrUTC (input, format, locale, strict, isUTC) {
+// TODO: Check what existing moments have in them
+// ts, off, locale, tz + parsing flags (only for new)
+export function quickCreateLocal(lts, locale, timeZone, flags) {
+ var local_ts_offset = computeOffset(lts, timeZone, flags);
+ return new Moment({local_ts[0], local_ts[1], locale, timeZone});
+}
+
+export function quickCreateUTC(uts, locale, timeZone) {
+ var offset = timeZone.offsetFromTimestamp(uts);
+ return new Moment({uts + offset, offset, locale, timeZone});
+}
+
+function computeOffset(lts, timeZone, flags) {
+ // TODO: Flags are being ignored. Take them into account some day
+
+ var of1 = timezone.offsetFromTimestamp(lts) // we treat local timestamp as unix to get
+ // a ballbpark estimate
+ var of2 = timezone.offsetFromTimestamp(lts - of1) // adjust local by probable offset
+ if (of1 == of2) {
+ // (lts, of1) is valid, but could be ambigous (second)
+ of3 = timezone.offsetFromTimestamp(lts - of1 - 6 * 60 * 60 * 1000); // subtract 6h to see if
+ // we're near DST
+ if (of1 === of3) {
+ return [lts, of1];
+ } else if (timezone.offsetFromTimestamp(lts - of3) === of3) {
+ // ambiguous, variants are [lts, of3], [lts, of1], of3 being
+ // the previous
+ return [lts, of3];
+ } else {
+ // there was DST shortly before [lts, of1], but it fully passed
+ return [lts, of1];
+ }
+ } else {
+ // we try a second time, this could happen around invalid time
+ var of3 = timezone.offsetFromTimestamp(lts - of2);
+ if (of3 === of2) {
+ return [lts, of2]
+ } else {
+ // invalid time!
+ if (of2 > of3) {
+ var tmp = of2; of2 = of3; of3 = tmp;
+ }
+ var dstGap = of3 - of2;
+ if (timezone.offsetFromTimestamp(lts + dstGap - of3) == of3) {
+ return [lts + dstGap, of3];
+ } else {
+ throw new Error("should never happen (test)");
+ }
+ }
+ }
+}
+
+export function createCollect (input, format, locale, strict, tz) {
var c = {};
if (locale === true || locale === false) {
}
// object construction must be done this way.
// https://github.com/moment/moment/issues/1423
- c._isAMomentObject = true;
- c._useUTC = c._isUTC = isUTC;
+ // c._isAMomentObject = true;
+ c._tz = tz;
c._l = locale;
c._i = input;
c._f = format;
import defaults from '../utils/defaults';
import getParsingFlags from './parsing-flags';
+// TODO(Iskren): The proper impl of this function, should:
+// - check if there is config._tzm, if there is, get the local time in that
+// fixed offset timezone
+// - otherwise, return the local date for the config._tz (quickCreateUTC(now(),
+// _l, _tz).year()/.month()/.date()
+// But then every moment object creation creates another object ... at least
+// not recursive, but much slower.
function currentDateArray(config) {
// hooks is actually the exported moment object
var nowValue = new Date(hooks.now());
- if (config._useUTC) {
- return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
- }
+ // if (config._useUTC) {
+ // return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
+ // }
return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
}
config._a[HOUR] = 0;
}
- config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
+ config._d = createUTCDate.apply(null, input);
// Apply timezone offset from input. The actual utcOffset can be changed
// with parseZone.
if (config._tzm != null) {
}
function dayOfYearFromWeekInfo(config) {
- var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
+ var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, now;
w = config._w;
if (w.GG != null || w.W != null || w.E != null) {
dow = 1;
doy = 4;
+ // TODO: NOW we can do this, revisit after making sure config._tz is an
+ // object at this point.
// TODO: We need to take the current isoWeekYear, but that depends on
// how we interpret now (local, utc, fixed offset). So create
// a now version of current config (take local/utc/offset flags, and
for (i = 0; i < config._f.length; i++) {
currentScore = 0;
tempConfig = copyConfig({}, config);
- if (config._useUTC != null) {
- tempConfig._useUTC = config._useUTC;
- }
tempConfig._f = config._f[i];
configFromStringAndFormat(tempConfig);
'discouraged and will be removed in an upcoming major release. Please refer to ' +
'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
function (config) {
- config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
+ config._d = new Date(config._i + (config._tz.type != 'local' ? ' UTC' : ''));
}
);
+++ /dev/null
-import { createLocalOrUTC } from './from-anything';
-
-export function createLocal (input, format, locale, strict) {
- return createLocalOrUTC(input, format, locale, strict, false);
-}
+++ /dev/null
-import { createLocalOrUTC } from './from-anything';
-
-export function createUTC (input, format, locale, strict) {
- return createLocalOrUTC(input, format, locale, strict, true).utc();
-}
} else if (duration == null) {// checks for null or undefined
duration = {};
} else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
+ // TODO: Do not createLocal, instead, use the zone of one of them, and
+ // align the other.
diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
duration = {};
import { Moment } from './constructor';
import { get, set } from './get-set';
-import { setMonth } from '../units/month';
+import { smartSetUTCMonth } from '../units/month';
import { createDuration } from '../duration/create';
import { deprecateSimple } from '../utils/deprecate';
import { hooks } from '../utils/hooks';
};
}
-export function addSubtract (mom, duration, isAdding, updateOffset) {
+export function addSubtract (mom, duration, isAdding) {
+ // TODO: Check for last argument usage, make sure its ok
var milliseconds = duration._milliseconds,
days = absRound(duration._days),
- months = absRound(duration._months);
+ months = absRound(duration._months),
+ d;
if (!mom.isValid()) {
// No op
return mom;
}
- updateOffset = updateOffset == null ? true : updateOffset;
-
- if (milliseconds) {
- mom = new Moment(mom);
- mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
- }
- if (days) {
- mom = set(mom, 'Date', get(mom, 'Date') + days * isAdding);
- }
- if (months) {
- mom = setMonth(mom, get(mom, 'Month') + months * isAdding);
- }
- if (updateOffset) {
- mom = hooks.updateOffset(mom, days || months);
+ if (months || days) {
+ d = new Date(mom._d);
+ if (months) {
+ // takes care of 31st Jan + 1m -> 28th Feb
+ smartSetUTCMonth(d, d.getUTCMonth() + months);
+ }
+ if (days) {
+ d.setUTCDate(d.getUTCDate() + days);
+ }
+ return quickCreateLocal(d.valueOf() + milliseconds, mom._l, mom._tz);
+ } else {
+ return quickCreateUTC(mom.unix() + milliseconds, mom._l, mom._tz);
}
- return mom;
+
+// if (milliseconds) {
+// // TODOv3 -- work on the config if necessary
+// // TODOv3 -- 1) order MS, D, M or M, D, MS
+// // TODOv3 -- 2) work on date object directly (all operations)
+// // TODOv3 -- 3) figure out updateOffset so it only happens once in
+// // constructor
+// mom = new Moment(mom);
+// mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
+// }
+// if (days) {
+// mom = set(mom, 'Date', get(mom, 'Date') + days * isAdding);
+// }
+// if (months) {
+// mom = setMonth(mom, get(mom, 'Month') + months * isAdding);
+// }
+// if (updateOffset) {
+// mom = hooks.updateOffset(mom, days || months);
+// }
+// return mom;
}
export var add = createAdder(1, 'add');
export function calendar (time, formats) {
// We want to compare the start of today, vs this.
// Getting start-of-today depends on whether we're local/utc/offset or not.
- var now = time || createLocal(),
+ var now = time != null ? createLocal(time) : createLocal(),
sod = cloneWithOffset(now, this).startOf('day'),
format = hooks.calendarFormat(this, sod) || 'sameElse';
var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
- return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
+ return this.format(output || this.localeData().calendar(format, this, now));
}
if (!this.isValid()) {
this._d = new Date(NaN);
}
+ this._isAMomentObject = true;
}
export function isMoment (obj) {
import isFunction from '../utils/is-function';
-export function makeGetSet (unit, keepTime) {
+export function makeGetSet (unit, msCoef) {
return function (value) {
if (value != null) {
- var mom = set(this, unit, value);
- return hooks.updateOffset(mom, keepTime);
+ return set(this, unit, value, msCoef);
} else {
return get(this, unit);
}
};
}
-export function get (mom, unit) {
+function get (mom, unit) {
return mom.isValid() ?
mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
}
-export function set (mom, unit, value) {
- if (mom.isValid()) {
- mom = new Moment(mom);
- mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
+function set (mom, unit, value, msCoef) {
+ if (!mom.isValid()) {
+ return mom;
+ // TODOv3 -- clone & modify config directly
+ }
+ var d, uts;
+ if (msCoef != null) {
+ // this is one of ms, second, minute, hour
+ uts = mom.unix();
+ uts += (unit - get(mom, unit)) * msCoef;
+ return quickCreateUTC(uts, mom._l, mom._tz);
+ } else {
+ // this is one of day, year. NOT month
+ d = new Date(mom._d);
+ d['setUTC' + unit](value);
+ return quickCreateLocal(d.valueOf(), mom._l, mom._tz);
}
- return mom;
}
+
// MOMENTS
export function stringGet (units) {
if (key === undefined) {
return this._locale._abbr;
} else {
- clone = new Moment(this);
newLocaleData = getLocale(key);
if (newLocaleData != null) {
- clone._locale = newLocaleData;
+ return quickCreateUTC(this.unix(), newLocaleData, this._tz);
}
- return clone;
+ return this;
}
}
// MOMENTS
-export var getSetDayOfMonth = makeGetSet('Date', true);
+export var getSetDayOfMonth = makeGetSet('Date');
// PRIORITY
// specified which hour he wants. So trying to maintain the same hour (in
// a new timezone) makes sense. Adding/subtracting hours does not follow
// this rule.
-export var getSetHour = makeGetSet('Hours', true);
+export var getSetHour = makeGetSet('Hours', 60 * 60 * 1000);
// PRIORITY
}
// MOMENTS
-export var getSetMillisecond = makeGetSet('Milliseconds', false);
+export var getSetMillisecond = makeGetSet('Milliseconds', 1);
// PRIORITY
// MOMENTS
-export var getSetMinute = makeGetSet('Minutes', false);
+export var getSetMinute = makeGetSet('Minutes', 60 * 1000);
// PRIORITY
// MOMENTS
export function setMonth (mom, value) {
- var dayOfMonth;
+ var d;
if (!mom.isValid()) {
// No op
}
}
- dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
- mom = new Moment(mom);
- mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
- return mom;
+ // TODOv3 -- there is a low-level set method, this should be one of its
+ // cases.
+ d = new Date(mom._d);
+ smartSetUTCMonth(d, value);
+ return quickCreateLocal(d.valueOf(), mom._l, mom._tz);
+}
+
+export function smartSetUTCMonth(d, month) {
+ var dayOfMonth = Math.min(d.getUTCDate(), daysInMonth(d.getUTCFullYear(), value));
+ d.setUTCMonth(value, dayOfMonth);
}
export function getSetMonth (value) {
if (value != null) {
- var mom = setMonth(this, value);
- return hooks.updateOffset(mom, true);
+ return setMonth(this, value);
} else {
return get(this, 'Month');
}
import { addRegexToken, matchOffset, matchShortOffset } from '../parse/regex';
import { addParseToken } from '../parse/token';
import { createLocal } from '../create/local';
-import { prepareConfig } from '../create/from-anything';
+import { quickCreateLocal, quickCreateUTC } from '../create/from-anything';
import { createUTC } from '../create/utc';
import isDate from '../utils/is-date';
import toInt from '../utils/to-int';
addRegexToken('Z', matchShortOffset);
addRegexToken('ZZ', matchShortOffset);
addParseToken(['Z', 'ZZ'], function (input, array, config) {
- config._useUTC = true;
config._tzm = offsetFromString(matchShortOffset, input);
});
// Return a moment from input, that is local/utc/zone equivalent to model.
export function cloneWithOffset(input, model) {
- var res, diff;
- if (model._isUTC) {
- res = new Moment(model);
- diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
- // Use low-level api, because this fn is low-level api.
- res._d.setTime(res._d.valueOf() + diff);
- return hooks.updateOffset(res, false);
- } else {
- return createLocal(input).local();
- }
+ // TODO: input could be a non-moment object, in certain cases
+ // createLocal("....z") --> is this UTC?
+ return changeTimezone(input, model._tz);
}
function getDateOffset (m) {
// Because Moment's external API is immutable and this hook will be defined
// externally (e.g. by Moment Timezone), this hook must return a (possibly new)
// Moment instance that reflects the correctly-updated offset.
-hooks.updateOffset = function (m) {
- return m;
-};
+// hooks.updateOffset = function (m) {
+// return m;
+// };
+// TODO: Fix usages, if any
// MOMENTS
// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
-export function getSetOffset (input, keepLocalTime, keepMinutes) {
- var mom = this,
- offset = mom._offset || 0,
- localAdjust;
- if (!mom.isValid()) {
- return input != null ? mom : NaN;
+
+function changeTimezone(mom, newTz, keepLocalTime) {
+ // TODO: Check if newTz is same as current (by comparing zone._key or sth)
+ // -- it is used a lot with possibly same tz (from cloneWithOffset)
+ if (keepLocalTime) {
+ return quickCreateLocal(mom._d.valueOf(), mom._l, newTz);
+ } else {
+ return quickCreateUTC(mom.unix(), mom._l, newTz);
}
+}
+
+export function getSetOffset (input, keepLocalTime, keepMinutes) {
if (input != null) {
if (typeof input === 'string') {
input = offsetFromString(matchShortOffset, input);
} else if (Math.abs(input) < 16 && !keepMinutes) {
input = input * 60;
}
- if (!mom._isUTC && keepLocalTime) {
- localAdjust = getDateOffset(mom);
- }
- mom = new Moment(mom);
- mom._offset = input;
- mom._isUTC = true;
- if (localAdjust != null) {
- mom = mom.add(localAdjust, 'm');
- }
- if (offset !== input) {
- if (!keepLocalTime || mom._changeInProgress) {
- mom = addSubtract(mom, createDuration(input - offset, 'm'), 1, false);
- } else if (!mom._changeInProgress) {
- mom._changeInProgress = true;
- mom = hooks.updateOffset(mom, true);
- mom._changeInProgress = null;
- }
- }
- return mom;
+ // not sure we need this no-op case, for speed I guess
+ // if (this._tz.type === 'fixed-offset' && this._tz.offset === input) {
+ // return mom;
+ // }
+ var newTz = FixedOffsetTimeZone.fromOffset(input);
+ return changeTimezone(this, newTz, keepLocalTime);
} else {
- return mom._isUTC ? offset : getDateOffset(mom);
+ return this._offset / 60000;
}
}
+
+
+// export function getSetOffset (input, keepLocalTime, keepMinutes) {
+// var mom = this,
+// offset = mom._offset || 0,
+// localAdjust;
+// if (!mom.isValid()) {
+// return input != null ? mom : NaN;
+// }
+// if (input != null) {
+// if (typeof input === 'string') {
+// input = offsetFromString(matchShortOffset, input);
+// if (input === null) {
+// return mom;
+// }
+// } else if (Math.abs(input) < 16 && !keepMinutes) {
+// input = input * 60;
+// }
+// if (!mom._isUTC && keepLocalTime) {
+// localAdjust = getDateOffset(mom);
+// }
+// // TODOv3 -- the new zone api should support 'is valid' that checks for
+// // a 'hole', and maybe ambiguity (overlap). This logic could be reorganized
+// // afterwards.
+// mom = new Moment(mom);
+// mom._offset = input;
+// mom._isUTC = true;
+// if (localAdjust != null) {
+// mom = mom.add(localAdjust, 'm');
+// }
+// if (offset !== input) {
+// if (!keepLocalTime || mom._changeInProgress) {
+// mom = addSubtract(mom, createDuration(input - offset, 'm'), 1, false);
+// } else if (!mom._changeInProgress) {
+// mom._changeInProgress = true;
+// mom = hooks.updateOffset(mom, true);
+// mom._changeInProgress = null;
+// }
+// }
+// return mom;
+// } else {
+// return mom._isUTC ? offset : getDateOffset(mom);
+// }
+// }
+
export function getSetZone (input, keepLocalTime) {
if (input != null) {
if (typeof input !== 'string') {
}
export function setOffsetToUTC (keepLocalTime) {
- return this.utcOffset(0, keepLocalTime);
+ return changeTimezone(this, FixedOffsetTimeZone.fromOffset(0), keepLocalTime);
}
export function setOffsetToLocal (keepLocalTime) {
- var ret = this;
- if (ret._isUTC) {
- ret = ret.utcOffset(0, keepLocalTime);
- ret._isUTC = false;
-
- if (keepLocalTime) {
- ret = ret.subtract(getDateOffset(ret), 'm');
- }
- }
- return ret;
+ return changeTimezone(this, LocalTimeZone.instance(), keepLocalTime);
}
export function setOffsetToParsedOffset () {
);
}
-export function isDaylightSavingTimeShifted () {
- if (!isUndefined(this._isDSTShifted)) {
- return this._isDSTShifted;
- }
+// TODO: We could do this properly, but I don't think we should.
+// Maybe expose the local -> [local, offset] function and let people shoot
+// themselves in the foot
+// export function isDaylightSavingTimeShifted () {
+// if (!isUndefined(this._isDSTShifted)) {
+// return this._isDSTShifted;
+// }
- var c = {};
+// var c = {};
- copyConfig(c, this);
- c = prepareConfig(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;
- }
+// 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;
-}
+// return this._isDSTShifted;
+// }
export function isLocal () {
- return this.isValid() ? !this._isUTC : false;
+ return this._tz.type == 'local';
}
export function isUtcOffset () {
- return this.isValid() ? this._isUTC : false;
+ return this._tz.type == 'fixed-offset';
}
export function isUtc () {
- return this.isValid() ? this._isUTC && this._offset === 0 : false;
+ return this._tz.type == 'fixed-offset' && this._tz.offset === 0;
}
// MOMENTS
-export var getSetSecond = makeGetSet('Seconds', false);
+export var getSetSecond = makeGetSet('Seconds', 1000);
// PRIORITY
import { daysInYear } from './year';
-import { createLocal } from '../create/local';
import { createUTCDate } from '../create/date-from-array';
// start-of-first-week - start-of-year
-import { Moment } from '../moment/constructor';
import { addFormatToken } from '../format/format';
import { addUnitAlias } from './aliases';
import { addUnitPriority } from './priorities';
import { weekOfYear, weeksInYear, dayOfYearFromWeeks } from './week-calendar-utils';
import toInt from '../utils/to-int';
import { hooks } from '../utils/hooks';
-import { createLocal } from '../create/local';
+import { quickCreateLocal } from '../create/from-anything';
import { createUTCDate } from '../create/date-from-array';
import { getSetDayOfMonth } from './day-of-month';
import { getSetMonth } from './month';
function setWeekAll(mom, weekYear, week, weekday, dow, doy) {
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
- date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
+ date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear),
+ d = new Date(mom._d);
- mom = new Moment(mom);
- mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'FullYear'](
- date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
- return mom;
+ // TODOv3 -- I guess the generic set method should accept all args that the Date
+ // object accepts.
+ d.setUTCFullYear(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
+ return quickCreateLocal(d.valueOf(), mom._l, mom._tz);
}
// PRIORITY
import { addRegexToken, match1to2, match2 } from '../parse/regex';
import { addWeekParseToken } from '../parse/token';
import toInt from '../utils/to-int';
-import { createLocal } from '../create/local';
import { weekOfYear } from './week-calendar-utils';
// FORMATTING
// MOMENTS
-export var getSetYear = makeGetSet('FullYear', true);
+export var getSetYear = makeGetSet('FullYear');
export function getIsLeapYear () {
return isLeapYear(this.year());