Skip to content

Instantly share code, notes, and snippets.

@island205
Created October 31, 2012 02:31
Show Gist options
  • Save island205/3984470 to your computer and use it in GitHub Desktop.
Save island205/3984470 to your computer and use it in GitHub Desktop.
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