Chinese holidays
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
data
test
.gitignore
.travis.yml
README.md
book.js
bundled.js
cache.js
days.js
index.js
package-lock.json
package.json

README.md

chinese-holidays

提供具有中国特色的休假安排或者工作日查询。

Install

npm install chinese-holidays

Usage

var ChineseHolidays = require('chinese-holidays');

ChineseHolidays.ready(function(book, err){
  if err != null {
    return
  }

  元旦 = new Date(2016, 0, 1)
  // 是否休假(含正常的周六、周日)
  book.isHoliday(元旦)     
  // true

  // 是否是工作日(含节假日的调休)
  book.isWorkingday(元旦)
  // fase


  // 列出已知的节假日
  book.all().forEach(function(holiday){
    console.log(holiday.name)
    console.log(holiday.days().map(function(date) { return moment(date).format('YYYY-MM-DD') }))
  })
  // 元旦
  // ["2016-01-01", "2016-01-02", "2016-01-03"]
  // ...

  // 列出所有的特殊日子(节假日和调休)
  book.events().forEach(function(event){
    console.log(event.name, event.days(), event.isHoliday(), event.isWorkingday())
  })
})

Support

References

License

The package is available as open source under the terms of the MIT License.