diff options
Diffstat (limited to 'bower_components/moment/src/lib/units')
| -rw-r--r-- | bower_components/moment/src/lib/units/day-of-week.js | 28 | ||||
| -rw-r--r-- | bower_components/moment/src/lib/units/day-of-year.js | 18 | ||||
| -rw-r--r-- | bower_components/moment/src/lib/units/millisecond.js | 38 | ||||
| -rw-r--r-- | bower_components/moment/src/lib/units/offset.js | 31 | ||||
| -rw-r--r-- | bower_components/moment/src/lib/units/year.js | 6 |
5 files changed, 76 insertions, 45 deletions
diff --git a/bower_components/moment/src/lib/units/day-of-week.js b/bower_components/moment/src/lib/units/day-of-week.js index 7af2408..a82f126 100644 --- a/bower_components/moment/src/lib/units/day-of-week.js +++ b/bower_components/moment/src/lib/units/day-of-week.js @@ -57,18 +57,20 @@ addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { // HELPERS function parseWeekday(input, locale) { - if (typeof input === 'string') { - if (!isNaN(input)) { - input = parseInt(input, 10); - } - else { - input = locale.weekdaysParse(input); - if (typeof input !== 'number') { - return null; - } - } + if (typeof input !== 'string') { + return input; + } + + if (!isNaN(input)) { + return parseInt(input, 10); } - return input; + + input = locale.weekdaysParse(input); + if (typeof input === 'number') { + return input; + } + + return null; } // LOCALES @@ -91,9 +93,7 @@ export function localeWeekdaysMin (m) { export function localeWeekdaysParse (weekdayName) { var i, mom, regex; - if (!this._weekdaysParse) { - this._weekdaysParse = []; - } + this._weekdaysParse = this._weekdaysParse || []; for (i = 0; i < 7; i++) { // make the regex if we don't have it already diff --git a/bower_components/moment/src/lib/units/day-of-year.js b/bower_components/moment/src/lib/units/day-of-year.js index 7c4d286..0c34fa3 100644 --- a/bower_components/moment/src/lib/units/day-of-year.js +++ b/bower_components/moment/src/lib/units/day-of-year.js @@ -26,18 +26,18 @@ addParseToken(['DDD', 'DDDD'], function (input, array, config) { //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday export function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) { - var d = createUTCDate(year, 0, 1).getUTCDay(); - var daysToAdd; - var dayOfYear; + var week1Jan = 6 + firstDayOfWeek - firstDayOfWeekOfYear, janX = createUTCDate(year, 0, 1 + week1Jan), d = janX.getUTCDay(), dayOfYear; + if (d < firstDayOfWeek) { + d += 7; + } - d = d === 0 ? 7 : d; - weekday = weekday != null ? weekday : firstDayOfWeek; - daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0); - dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1; + weekday = weekday != null ? 1 * weekday : firstDayOfWeek; + + dayOfYear = 1 + week1Jan + 7 * (week - 1) - d + weekday; return { - year : dayOfYear > 0 ? year : year - 1, - dayOfYear : dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear + year: dayOfYear > 0 ? year : year - 1, + dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear }; } diff --git a/bower_components/moment/src/lib/units/millisecond.js b/bower_components/moment/src/lib/units/millisecond.js index 2fb73af..134d88e 100644 --- a/bower_components/moment/src/lib/units/millisecond.js +++ b/bower_components/moment/src/lib/units/millisecond.js @@ -16,12 +16,26 @@ addFormatToken(0, ['SS', 2], 0, function () { return ~~(this.millisecond() / 10); }); -function milliseconds (token) { - addFormatToken(0, [token, 3], 0, 'millisecond'); -} +addFormatToken(0, ['SSS', 3], 0, 'millisecond'); +addFormatToken(0, ['SSSS', 4], 0, function () { + return this.millisecond() * 10; +}); +addFormatToken(0, ['SSSSS', 5], 0, function () { + return this.millisecond() * 100; +}); +addFormatToken(0, ['SSSSSS', 6], 0, function () { + return this.millisecond() * 1000; +}); +addFormatToken(0, ['SSSSSSS', 7], 0, function () { + return this.millisecond() * 10000; +}); +addFormatToken(0, ['SSSSSSSS', 8], 0, function () { + return this.millisecond() * 100000; +}); +addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { + return this.millisecond() * 1000000; +}); -milliseconds('SSS'); -milliseconds('SSSS'); // ALIASES @@ -32,11 +46,19 @@ addUnitAlias('millisecond', 'ms'); addRegexToken('S', match1to3, match1); addRegexToken('SS', match1to3, match2); addRegexToken('SSS', match1to3, match3); -addRegexToken('SSSS', matchUnsigned); -addParseToken(['S', 'SS', 'SSS', 'SSSS'], function (input, array) { + +var token; +for (token = 'SSSS'; token.length <= 9; token += 'S') { + addRegexToken(token, matchUnsigned); +} + +function parseMs(input, array) { array[MILLISECOND] = toInt(('0.' + input) * 1000); -}); +} +for (token = 'S'; token.length <= 9; token += 'S') { + addParseToken(token, parseMs); +} // MOMENTS export var getSetMillisecond = makeGetSet('Milliseconds', false); diff --git a/bower_components/moment/src/lib/units/offset.js b/bower_components/moment/src/lib/units/offset.js index 75aeb02..33288c0 100644 --- a/bower_components/moment/src/lib/units/offset.js +++ b/bower_components/moment/src/lib/units/offset.js @@ -1,11 +1,12 @@ 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'; @@ -67,7 +68,6 @@ export function cloneWithOffset(input, model) { } else { return createLocal(input).local(); } - return model._isUTC ? createLocal(input).zone(model._offset || 0) : createLocal(input).local(); } function getDateOffset (m) { @@ -167,12 +167,7 @@ export function setOffsetToParsedOffset () { } export function hasAlignedHourOffset (input) { - if (!input) { - input = 0; - } - else { - input = createLocal(input).utcOffset(); - } + input = input ? createLocal(input).utcOffset() : 0; return (this.utcOffset() - input) % 60 === 0; } @@ -185,12 +180,24 @@ export function isDaylightSavingTime () { } 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; + } + + 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 false; + return this._isDSTShifted; } export function isLocal () { diff --git a/bower_components/moment/src/lib/units/year.js b/bower_components/moment/src/lib/units/year.js index 4d8a03b..cc32b55 100644 --- a/bower_components/moment/src/lib/units/year.js +++ b/bower_components/moment/src/lib/units/year.js @@ -29,7 +29,10 @@ addRegexToken('YYYY', match1to4, match4); addRegexToken('YYYYY', match1to6, match6); addRegexToken('YYYYYY', match1to6, match6); -addParseToken(['YYYY', 'YYYYY', 'YYYYYY'], YEAR); +addParseToken(['YYYYY', 'YYYYYY'], YEAR); +addParseToken('YYYY', function (input, array) { + array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input); +}); addParseToken('YY', function (input, array) { array[YEAR] = hooks.parseTwoDigitYear(input); }); @@ -57,4 +60,3 @@ export var getSetYear = makeGetSet('FullYear', false); export function getIsLeapYear () { return isLeapYear(this.year()); } - |
