Created
January 21, 2020 23:04
-
-
Save TehShrike/c7364710abe03e29b28e8564f28f54d5 to your computer and use it in GitHub Desktop.
The names of the days of the week using browser locale
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 anArbitrarySundayEarlyInTheMonth = new Date(2020, 0, 5) | |
const dayNumbers = [ 0, 1, 2, 3, 4, 5, 6 ] | |
const formatter = new Intl.DateTimeFormat(undefined, { | |
weekday: `short`, | |
}) | |
const weekdayNames = dayNumbers.map(dayNumber => { | |
const date = new Date(anArbitrarySundayEarlyInTheMonth) | |
date.setDate(date.getDate() + dayNumber) | |
return formatter.format(date) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment