Last active
April 5, 2017 18:37
-
-
Save Sivli-Embir/95e37b7bc2736bcc46715758c2a3ffd9 to your computer and use it in GitHub Desktop.
This file contains 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
import {getCurrentWeek} from 'weekSolution'; | |
// Friday: -2 | |
getCurrentWeek(-2) | |
// Saturday: -1 | |
getCurrentWeek(-2) | |
// Sunday: 0 | |
getCurrentWeek(0) | |
// Monday: 1 | |
getCurrentWeek(1) | |
// Tuesday: 2 | |
getCurrentWeek(2) | |
// Wednesday: 3 | |
getCurrentWeek(3) | |
// Thursday: 4 | |
getCurrentWeek(4) |
This file contains 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
import moment from 'moment'; | |
moment.defineLocale('custom-0', {parentLocale: 'en', week:{dow : 0}}); | |
moment.defineLocale('custom-1', {parentLocale: 'en', week:{dow : 1}}); | |
moment.defineLocale('custom-2', {parentLocale: 'en', week:{dow : 2}}); | |
moment.defineLocale('custom-3', {parentLocale: 'en', week:{dow : 3}}); | |
moment.defineLocale('custom-4', {parentLocale: 'en', week:{dow : 4}}); | |
moment.defineLocale('custom--2', {parentLocale: 'en', week:{dow : -2}}); | |
moment.defineLocale('custom--1', {parentLocale: 'en', week:{dow : -1}}); | |
export function getCurrentWeek(dayOffSet) { | |
moment.locale(`custom-${dayOffSet}`) //always set this to override locale settings. | |
let date = moment() | |
return { | |
year: date.year(), | |
week: date.week() | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment