Skip to content

Instantly share code, notes, and snippets.

@digitarhythm
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitarhythm/88bf4ffe31423fbe8c10 to your computer and use it in GitHub Desktop.
Save digitarhythm/88bf4ffe31423fbe8c10 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/coffee-script/1.7.1/coffee-script.min.js"></script>
<script type="text/coffeescript">
window.onload = ->
disp = "<pre>Su Ma Th We Tu Fr Su<br>"
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
now = new Date()
y = now.getFullYear()
m = now.getMonth()
d = now.getDate()
fd = new Date(y, m, 1, 12, 0, 0, 0)
w = fd.getDay()
for i in [0...w]
disp += " "
mday = days[m]
if (m == 1)
mday += (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
for i in [1..mday]
c = if (i < 10) then " " else ""
disp += c+i+" "
if ((i + w) % 7 == 0)
disp += "<br>"
disp += "</pre>"
element = document.getElementById("calendar")
element.innerHTML = disp
</script>
</head>
<body>
<div id="calendar"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment