Created
March 4, 2018 01:30
-
-
Save thiagoh/884f1f80d85d338dc72fbfcc7eb8dbdd to your computer and use it in GitHub Desktop.
Updating first week DOW and DAY in moment.js Raw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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