1 import { addFormatToken } from '../format/format';
2 import { addUnitAlias } from './aliases';
3 import { addRegexToken, match1to2, match2 } from '../parse/regex';
4 import { addWeekParseToken } from '../parse/token';
5 import toInt from '../utils/to-int';
6 import { createLocal } from '../create/local';
7 import { weekOfYear } from './week-calendar-utils';
11 addFormatToken('w', ['ww', 2], 'wo', 'week');
12 addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
16 addUnitAlias('week', 'w');
17 addUnitAlias('isoWeek', 'W');
21 addRegexToken('w', match1to2);
22 addRegexToken('ww', match1to2, match2);
23 addRegexToken('W', match1to2);
24 addRegexToken('WW', match1to2, match2);
26 addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
27 week[token.substr(0, 1)] = toInt(input);
34 export function localeWeek (mom) {
35 return weekOfYear(mom, this._week.dow, this._week.doy).week;
38 export var defaultLocaleWeek = {
39 dow : 0, // Sunday is the first day of the week.
40 doy : 6 // The week that contains Jan 1st is the first week of the year.
43 export function localeFirstDayOfWeek () {
44 return this._week.dow;
47 export function localeFirstDayOfYear () {
48 return this._week.doy;
53 export function getSetWeek (input) {
54 var week = this.localeData().week(this);
55 return input == null ? week : this.add((input - week) * 7, 'd');
58 export function getSetISOWeek (input) {
59 var week = weekOfYear(this, 1, 4).week;
60 return input == null ? week : this.add((input - week) * 7, 'd');