module.exports = {
name: 'clone',
onComplete: function(){},
- fn: function(){base.clone();},
+ fn: function(){moment(base);},
async: true
};
res.months = other.month() - base.month() +
(other.year() - base.year()) * 12;
- if (base.clone().add(res.months, 'M').isAfter(other)) {
+ if (base.add(res.months, 'M').isAfter(other)) {
--res.months;
}
- res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
+ res.milliseconds = +other - +(base.add(res.months, 'M'));
return res;
}
+++ /dev/null
-import { Moment } from './constructor';
-
-export function clone () {
- return new Moment(this);
-}
if (units === 'millisecond') {
return this.valueOf() > localInput.valueOf();
} else {
- return localInput.valueOf() < this.clone().startOf(units).valueOf();
+ return localInput.valueOf() < this.startOf(units).valueOf();
}
}
if (units === 'millisecond') {
return this.valueOf() < localInput.valueOf();
} else {
- return this.clone().endOf(units).valueOf() < localInput.valueOf();
+ return this.endOf(units).valueOf() < localInput.valueOf();
}
}
return this.valueOf() === localInput.valueOf();
} else {
inputMs = localInput.valueOf();
- return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
+ return this.startOf(units).valueOf() <= inputMs && inputMs <= this.endOf(units).valueOf();
}
}
// difference in months
var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
// b is in (anchor - 1 month, anchor + 1 month)
- anchor = a.clone().add(wholeMonthDiff, 'months'),
+ anchor = a.add(wholeMonthDiff, 'months'),
anchor2, adjust;
if (b - anchor < 0) {
- anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
+ anchor2 = a.add(wholeMonthDiff - 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor - anchor2);
} else {
- anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
+ anchor2 = a.add(wholeMonthDiff + 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor2 - anchor);
}
hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
export function toString () {
- return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
+ return this.locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
}
export function toISOString() {
if (!this.isValid()) {
return null;
}
- var m = this.clone().utc();
+ var m = this.utc();
if (m.year() < 0 || m.year() > 9999) {
return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
}
import { add, subtract } from './add-subtract';
import { calendar, getCalendarFormat } from './calendar';
-import { clone } from './clone';
import { isBefore, isBetween, isSame, isAfter, isSameOrAfter, isSameOrBefore } from './compare';
import { diff } from './diff';
import { format, toString, toISOString, inspect } from './format';
// MOMENTS
export function getSetDayOfYear (input) {
- var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
+ var dayOfYear = Math.round((this.startOf('day') - this.startOf('year')) / 864e5) + 1;
return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
}
import zeroFill from '../utils/zero-fill';
import { createDuration } from '../duration/create';
import { addSubtract } from '../moment/add-subtract';
-import { isMoment, copyConfig } from '../moment/constructor';
+import { Moment, isMoment, copyConfig } from '../moment/constructor';
import { addFormatToken } from '../format/format';
import { addRegexToken, matchOffset, matchShortOffset } from '../parse/regex';
import { addParseToken } from '../parse/token';
export function cloneWithOffset(input, model) {
var res, diff;
if (model._isUTC) {
- res = model.clone();
+ 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);
export function isDaylightSavingTime () {
return (
- this.utcOffset() > this.clone().month(0).utcOffset() ||
- this.utcOffset() > this.clone().month(5).utcOffset()
+ this.utcOffset() > new Moment(this).month(0).utcOffset() ||
+ this.utcOffset() > new Moment(this).month(5).utcOffset()
);
}