Skip to content

Instantly share code, notes, and snippets.

@thiagoh
Created March 4, 2018 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagoh/884f1f80d85d338dc72fbfcc7eb8dbdd to your computer and use it in GitHub Desktop.
Save thiagoh/884f1f80d85d338dc72fbfcc7eb8dbdd to your computer and use it in GitHub Desktop.
Updating first week DOW and DAY in moment.js Raw
const moment = require('moment');
const createDates = () => {
return [
moment({ year: 2015, month: 11, day: 25 }),
moment({ year: 2015, month: 11, day: 26 }),
moment({ year: 2015, month: 11, day: 27 }),
moment({ year: 2015, month: 11, day: 28 }),
moment({ year: 2015, month: 11, day: 29 }),
moment({ year: 2015, month: 11, day: 30 }),
moment({ year: 2015, month: 11, day: 31 }),
moment({ year: 2016, month: 0, day: 1 }),
moment({ year: 2016, month: 0, day: 2 }),
moment({ year: 2016, month: 0, day: 3 }),
moment({ year: 2016, month: 0, day: 4 }),
moment({ year: 2016, month: 0, day: 5 }),
moment({ year: 2016, month: 0, day: 6 }),
];
};
console.log('#################');
createDates().forEach(date => {
console.log(`en: ${date} / year ${date.weekYear()} / date.week() ${date.week()}`);
});
moment.locale('en-am', {
// customizations.
week: { dow: 0, doy: 3 },
});
console.log('#################');
createDates().forEach(date => {
console.log(`en: ${date} / year ${date.weekYear()} / date.week() ${date.week()}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment