NAME JapanseHolidays - Japanese holidays calculation library SYNOPSIS isH = JapaneseHolidays.isHoliday(new Date(2007, 9 - 1, 23)); name = JapaneseHolidays.getHolidayName(new Date(2007, 9 - 1, 23)); DESCRIPTION This is a library for testing if a date is a Japanese holiday (precisely, "Shukujitsu" or "Furikae Kyuujitsu") or not. Also you can get the holiday name written in Japanese. FUNCTIONS isHoliday Tests a specified date is a Japanese holiday or not. isH = JapaneseHolidays.isHoliday(new Date(2007, 9 - 1, 23)); // is true isH = JapaneseHolidays.isHoliday(new Date(2007, 4 - 1, 29)); // is true isH = JapaneseHolidays.isHoliday(new Date(2007, 4 - 1, 30)); // is true because this date is a "furikae kyuujitsu". isH = JapaneseHolidays.isHoliday(new Date(2007, 4 - 1, 30), false); // is false with passing includesFurikaeKyujitsu to false. getHolidayName Returns the holiday name (written in Japanese) for a date if the date is a holiday, or returns the empty string if the date is not a holiday. name = JapaneseHolidays.getHolidayName(new Date(2007, 9 - 1, 23)); // is '秋分の日' (<- a holiday name written in Japanese) name = JapaneseHolidays.getHolidayName(new Date(2007, 4 - 1, 29)); // is '昭和の日' name = JapaneseHolidays.getHolidayName(new Date(2007, 4 - 1, 30)); // is '振替休日' name = JapaneseHolidays.getHolidayName(new Date(2007, 4 - 1, 30), false); // is '' with passing includesFurikaeKyujitsu to false. getHolidayAndNames Returns an array of arrays of dates of holidays and names in a year or in a month. The first element of the nested array is a date of a holiday, and the second element is the name of that holiday. holidays = JapaneseHolidays.getHolidayAndNames(2007, 5 - 1); // holidays in a month for (i = 0; i < holidays.length; i++) { date = holidays[i][0]; name = holidays[i][1]; } // more examples holidays = JapaneseHolidays.getHolidayAndNames(2007); // holidays in a year holidays = JapaneseHolidays.getHolidayAndNames(2007, 9 - 1, false); // holidays excluding FurikaeKyuujitsu's. EXAMPLES // usage of isHoliday() to prevent computing repeatedly holidays in a month. year = 2007; month = 5 - 1; holidays = JapaneseHolidays.getHolidayAndNames(year, month); endDate = JapaneseHolidays.getEndDateInMonth(year, month); for (var d = 1; d < endDate.getDate(); d++) { dt = new Date(year, month, d); isH = JapaneseHolidays.isHoliday(dt, undefined, holidays); name = JapaneseHolidays.getHolidayName(dt, undefined, holidays); } CHANGES ver. 1.0.3 Fixed the calculation of Shunbun days and Shuubun days. The current version passes the test for years between 1948 and 2030, and is supposed to be correct until year 2150. ver. 1.0.2 Added dojo.provide(). ver. 1.0.1 Fixed a bug. Both isHoliday() and getHolidayName() didn't handle dates having non-zero (that is, not 00:00:00) time part. ver. 1.0 Initial release. AUTHOR Hioraki Nakamura COPYRIGHT This program is licensed under MIT license. Copyright (C) 2007 Hiroaki Nakamura Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.