.humanize(!withoutSuffix);
return this.localeData().invalidDate();
function toNow(withoutSuffix) {
return this.to(createLocal(), withoutSuffix);
// If passed a locale key, it will set the locale for this
// instance. Otherwise, it will return the locale configuration
// variables for this instance.
return this._locale._abbr;
newLocaleData = getLocale(key);
if (newLocaleData != null) {
this._locale = newLocaleData;
'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
return this.localeData();
var MS_PER_SECOND = 1000,
MS_PER_MINUTE = 60 * MS_PER_SECOND,
MS_PER_HOUR = 60 * MS_PER_MINUTE,
MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
// actual modulo - handles negative numbers (for dates before 1970):
function mod$1(dividend, divisor) {
return ((dividend % divisor) + divisor) % divisor;
function localStartOfDate(y, m, d) {
// the date constructor remaps years 0-99 to 1900-1999
// preserve leap years using a full 400 year cycle, then reset
return new Date(y + 400, m, d) - MS_PER_400_YEARS;
return new Date(y, m, d).valueOf();
function utcStartOfDate(y, m, d) {
// Date.UTC remaps years 0-99 to 1900-1999
// preserve leap years using a full 400 year cycle, then reset
return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
return Date.UTC(y, m, d);
function startOf(units) {
units = normalizeUnits(units);
if (units === undefined || units === 'millisecond' || !this.isValid()) {
startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
time = startOfDate(this.year(), 0, 1);
this.month() - (this.month() % 3),
time = startOfDate(this.year(), this.month(), 1);
this.date() - this.weekday()
this.date() - (this.isoWeekday() - 1)
time = startOfDate(this.year(), this.month(), this.date());
time = this._d.valueOf();
time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
time = this._d.valueOf();
time -= mod$1(time, MS_PER_MINUTE);
time = this._d.valueOf();
time -= mod$1(time, MS_PER_SECOND);
hooks.updateOffset(this, true);
units = normalizeUnits(units);
if (units === undefined || units === 'millisecond' || !this.isValid()) {
startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
time = startOfDate(this.year() + 1, 0, 1) - 1;
this.month() - (this.month() % 3) + 3,
time = startOfDate(this.year(), this.month() + 1, 1) - 1;
this.date() - this.weekday() + 7
this.date() - (this.isoWeekday() - 1) + 7
time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
time = this._d.valueOf();
time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
time = this._d.valueOf();
time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
time = this._d.valueOf();
time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
hooks.updateOffset(this, true);
return this._d.valueOf() - (this._offset || 0) * 60000;
return Math.floor(this.valueOf() / 1000);
return new Date(this.valueOf());
milliseconds: m.milliseconds(),
// new Date(NaN).toJSON() === null
return this.isValid() ? this.toISOString() : null;
function parsingFlags() {
return extend({}, getParsingFlags(this));
return getParsingFlags(this).overflow;
function creationData() {
addFormatToken('N', 0, 0, 'eraAbbr');
addFormatToken('NN', 0, 0, 'eraAbbr');
addFormatToken('NNN', 0, 0, 'eraAbbr');
addFormatToken('NNNN', 0, 0, 'eraName');
addFormatToken('NNNNN', 0, 0, 'eraNarrow');
addFormatToken('y', ['y', 1], 'yo', 'eraYear');
addFormatToken('y', ['yy', 2], 0, 'eraYear');
addFormatToken('y', ['yyy', 3], 0, 'eraYear');
addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
addRegexToken('N', matchEraAbbr);
addRegexToken('NN', matchEraAbbr);
addRegexToken('NNN', matchEraAbbr);
addRegexToken('NNNN', matchEraName);
addRegexToken('NNNNN', matchEraNarrow);
addParseToken(['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], function (
var era = config._locale.erasParse(input, token, config._strict);
getParsingFlags(config).era = era;
getParsingFlags(config).invalidEra = input;
addRegexToken('y', matchUnsigned);
addRegexToken('yy', matchUnsigned);
addRegexToken('yyy', matchUnsigned);
addRegexToken('yyyy', matchUnsigned);
addRegexToken('yo', matchEraYearOrdinal);
addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
addParseToken(['yo'], function (input, array, config, token) {
if (config._locale._eraYearOrdinalRegex) {
match = input.match(config._locale._eraYearOrdinalRegex);
if (config._locale.eraYearOrdinalParse) {
array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
array[YEAR] = parseInt(input, 10);
function localeEras(m, format) {
eras = this._eras || getLocale('en')._eras;
for (i = 0, l = eras.length; i < l; ++i) {
switch (typeof eras[i].since) {
date = hooks(eras[i].since).startOf('day');
eras[i].since = date.valueOf();
switch (typeof eras[i].until) {
eras[i].until = +Infinity;
date = hooks(eras[i].until).startOf('day').valueOf();
eras[i].until = date.valueOf();
function localeErasParse(eraName, format, strict) {
eraName = eraName.toUpperCase();
for (i = 0, l = eras.length; i < l; ++i) {
name = eras[i].name.toUpperCase();
abbr = eras[i].abbr.toUpperCase();
narrow = eras[i].narrow.toUpperCase();
if (narrow === eraName) {
} else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
function localeErasConvertYear(era, year) {
var dir = era.since <= era.until ? +1 : -1;
if (year === undefined) {
return hooks(era.since).year();
return hooks(era.since).year() + (year - era.offset) * dir;
eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
val = this.startOf('day').valueOf();
if (eras[i].since <= val && val <= eras[i].until) {
if (eras[i].until <= val && val <= eras[i].since) {
function getEraNarrow() {
eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
val = this.startOf('day').valueOf();
if (eras[i].since <= val && val <= eras[i].until) {
if (eras[i].until <= val && val <= eras[i].since) {
eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
val = this.startOf('day').valueOf();
if (eras[i].since <= val && val <= eras[i].until) {
if (eras[i].until <= val && val <= eras[i].since) {
eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
dir = eras[i].since <= eras[i].until ? +1 : -1;
val = this.startOf('day').valueOf();
(eras[i].since <= val && val <= eras[i].until) ||
(eras[i].until <= val && val <= eras[i].since)
(this.year() - hooks(eras[i].since).year()) * dir +
function erasNameRegex(isStrict) {
if (!hasOwnProp(this, '_erasNameRegex')) {
computeErasParse.call(this);
return isStrict ? this._erasNameRegex : this._erasRegex;
function erasAbbrRegex(isStrict) {
if (!hasOwnProp(this, '_erasAbbrRegex')) {
computeErasParse.call(this);
return isStrict ? this._erasAbbrRegex : this._erasRegex;
function erasNarrowRegex(isStrict) {