Sha256: 8ece867c04fea2c5deeed7187dd0a4acefdaaad77c5c29defd525eb56e9380d3

Contents?: true

Size: 1.51 KB

Versions: 9

Compression:

Stored size: 1.51 KB

Contents

import { makeGetSet } from '../moment/get-set';
import { addFormatToken } from '../format/format';
import { addUnitAlias } from './aliases';
import { addRegexToken, match1to2, match1to4, match1to6, match2, match4, match6, matchSigned } from '../parse/regex';
import { addParseToken } from '../parse/token';
import { hooks } from '../utils/hooks';
import { YEAR } from './constants';
import toInt from '../utils/to-int';

// FORMATTING

addFormatToken(0, ['YY', 2], 0, function () {
    return this.year() % 100;
});

addFormatToken(0, ['YYYY',   4],       0, 'year');
addFormatToken(0, ['YYYYY',  5],       0, 'year');
addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');

// ALIASES

addUnitAlias('year', 'y');

// PARSING

addRegexToken('Y',      matchSigned);
addRegexToken('YY',     match1to2, match2);
addRegexToken('YYYY',   match1to4, match4);
addRegexToken('YYYYY',  match1to6, match6);
addRegexToken('YYYYYY', match1to6, match6);

addParseToken(['YYYY', 'YYYYY', 'YYYYYY'], YEAR);
addParseToken('YY', function (input, array) {
    array[YEAR] = hooks.parseTwoDigitYear(input);
});

// HELPERS

export function daysInYear(year) {
    return isLeapYear(year) ? 366 : 365;
}

function isLeapYear(year) {
    return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}

// HOOKS

hooks.parseTwoDigitYear = function (input) {
    return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
};

// MOMENTS

export var getSetYear = makeGetSet('FullYear', false);

export function getIsLeapYear () {
    return isLeapYear(this.year());
}

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
sedge_cms-0.0.1 vendor/assets/components/moment/src/lib/units/year.js
date_picker-0.0.6 test/dummy/vendor/assets/components/moment/src/lib/units/year.js
date_picker-0.0.5 test/dummy/vendor/assets/components/moment/src/lib/units/year.js
date_picker-0.0.4 test/dummy/vendor/assets/components/moment/src/lib/units/year.js
date_picker-0.0.3 test/dummy/vendor/assets/components/moment/src/lib/units/year.js
date_picker-0.0.2 test/dummy/vendor/assets/components/moment/src/lib/units/year.js
date_picker-0.0.1 test/dummy/vendor/assets/components/moment/src/lib/units/year.js
puppet-herald-0.8.1 lib/puppet-herald/public/bower_components/moment/src/lib/units/year.js
puppet-herald-0.8.0 lib/puppet-herald/public/bower_components/moment/src/lib/units/year.js