Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function daysInMonth (year, month) {
return /8|3|5|10/.test(month) ? 30 : month === 1 ? (!(year % 4) && year % 100) || !(year % 400) ? 29 : 28 : 31
}
function formatDate (date, format, translation) {
translation = (!translation) ? en : translation
let year = date.getFullYear()
let month = date.getMonth() + 1
let day = date.getDate()
let str = format
.replace(/dd/, ('0' + day).slice(-2))
.replace(/d/, day)
.replace(/yyyy/, year)
.replace(/yy/, String(year).slice(2))
.replace(/MMMM/, this.getMonthName(date.getMonth(), translation.months))
.replace(/MMM/, this.getMonthNameAbbr(date.getMonth(), translation.monthsAbbr))
.replace(/MM/, ('0' + month).slice(-2))
.replace(/M(?!a|ä|e)/, month)
.replace(/su/, this.getNthSuffix(date.getDate()))
.replace(/D(?!e|é|i)/, this.getDayNameAbbr(date, translation.days))
return str
},
@Yang03

This comment has been minimized.

Copy link
Owner Author

commented Jun 13, 2018

function createDateArray (start, end) {
let dates = []
while (start <= end) {
dates.push(new Date(start))
start = new Date(start).setDate(new Date(start).getDate() + 1)
}
return dates
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.