Created
October 31, 2012 02:31
-
-
Save island205/3984470 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
getDaysByMonth = (date = new Date(), fill=true, chinese = true) -> | |
date.setDate(1) | |
day = date.getDay() | |
month = date.getMonth() | |
days = [] | |
while date.getMonth() == month | |
days.push new Date(date.getTime()) | |
date.setDate(date.getDate() + 1) | |
monthCount = days.length | |
if fill | |
if chinese | |
day = day || 7 | |
for i in [day...1] | |
days.unshift "--" | |
for i in [0...(7 - (monthCount + (day - 1)) % 7)] | |
days.push "--" | |
else | |
for i in [day..1] | |
days.unshift "--" | |
for i in [1...(7 - (monthCount + (day - 1)) % 7)] | |
days.push "--" | |
days | |
console.log getDaysByMonth new Date(),true,true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment