Last active
April 9, 2019 13:08
-
-
Save fmunirdev/49d5536c3c4ed5aea6bae253e49b5f47 to your computer and use it in GitHub Desktop.
UOG Boys Hostel - Mess Attendance Email Template
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
<script> | |
function customCalendar(year, month) { | |
month--; | |
let d = new Date(year, month); | |
let firstDay = d.getDay(); | |
let date = 1, dateIter = 1; | |
var table = "<table>"; | |
table += "<tr><th colspan=14>" + d.toLocaleString('en-us', { month: 'long' }) + " " + d.getFullYear() + "</th></tr>"; | |
table += "<tr>"; | |
table += "<th colspan=2>Mon</th>"; | |
table += "<th colspan=2>Tue</th>"; | |
table += "<th colspan=2>Wed</th>"; | |
table += "<th colspan=2>Thu</th>"; | |
table += "<th colspan=2>Fri</th>"; | |
table += "<th colspan=2>Sat</th>"; | |
table += "<th colspan=2>Sun</th>"; | |
table += "</tr>"; | |
for (let i = 0; i < 6; i++) { | |
// creates a table row | |
table += "<tr>"; | |
//creating individual cells, filing them up with data. | |
date = dateIter; | |
for (let j = 1; j <= 7; j++) { | |
if (i === 0 && j < firstDay) { | |
table += "<td colspan=2></td>"; | |
} else if (date > daysInMonth(month, year)) { | |
break; | |
} else { | |
let d = new Date(year, month, date); | |
table += "<th colspan=2>" + d.getDate() + "-" + d.toLocaleString('en-us', { month: 'short' }) + "</th>"; | |
date++; | |
} | |
} | |
table += "</tr>"; | |
// creates a table row | |
table += "<tr>"; | |
//creating individual cells, filing them up with data. | |
date = dateIter; | |
for (let j = 1; j <= 7; j++) { | |
if (i === 0 && j < firstDay) { | |
table += "<td></td>"; | |
table += "<td></td>"; | |
} else if (date > daysInMonth(month, year)) { | |
break; | |
} else { | |
let currentDate = new Date(year, month, date); | |
table += "<td>" + "L" + "</td>"; | |
table += "<td>" + "D" + "</td>"; | |
date++; | |
dateIter++; | |
} | |
} | |
table += "</tr>"; | |
} | |
return table; | |
} | |
function daysInMonth(iMonth, iYear) { | |
return 32 - new Date(iYear, iMonth, 32).getDate(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment