Last active
August 29, 2015 14:26
-
-
Save vandernoud/94f577ee1092953f5f12 to your computer and use it in GitHub Desktop.
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
var getLastDayOfMonth = function(){ | |
var date = new Date(); | |
var lastDay = new Array([]); | |
lastDay[0] = "31 januari"; | |
lastDay[1] = "28 februari"; | |
lastDay[2] = "31 maart"; | |
lastDay[3] = "30 april"; | |
lastDay[4] = "31 mei"; | |
lastDay[5] = "30 juni"; | |
lastDay[6] = "31 juli"; | |
lastDay[7] = "31 augustus"; | |
lastDay[8] = "30 september"; | |
lastDay[9] = "31 oktober"; | |
lastDay[10] = "30 november"; | |
lastDay[11] = "31 december"; | |
// Check voor schrikkeljaar | |
if(date.getFullYear() % 4 === 0){ | |
lastDay[1] = "29 februari"; | |
} | |
var lastDayThisMonth = lastDay[date.getMonth()]; | |
return lastDayThisMonth; | |
} | |
var addLastDayOfMonth = function(){ | |
var dateToAdd = getLastDayOfMonth(); | |
var positionToAddDate = document.getElementById('copy3').childNodes[0]; | |
positionToAddDate.appendChild( document.createTextNode(dateToAdd) ); | |
} | |
addLastDayOfMonth(); | |
var setCountdownDate = function(){ | |
var date = new Date(); | |
var lastDay = new Date(date.getYear(), date.getMonth() + 1, 0).getDate(); | |
var currentDay = date.getDate(); | |
var daysUntilEndOfMonth = lastDay - currentDay; | |
var pancakeText = ''; | |
if(daysUntilEndOfMonth === 0){ | |
pancakeText = 'Laatste dag'; | |
}else if(daysUntilEndOfMonth === 1){ | |
pancakeText = 'Nog ' + daysUntilEndOfMonth + ' dag'; | |
}else if(daysUntilEndOfMonth <= 5){ | |
pancakeText = 'Nog ' + daysUntilEndOfMonth + ' dagen'; | |
} | |
console.log(pancakeText); | |
//return pancakeText; | |
}; | |
setCountdownDate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment