// ========================================================
// jp-holidays.js ---- ç¥æ—¥å–å¾—ã®ãŸã‚ã® Date æ‹¡å¼µ
// Copyright 2008 Kiyoshi Sakai
// 2008/06/23 - JSã§ã®æœ€åˆã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³
// 2008/09/25 - æ˜å’Œ23(1948)å¹´ã‹ã‚‰ã®éŽåŽ»ã‚’æ„è˜ã—ã¾ã—ãŸ
// å‚考ã«ã—ãŸã‚µã‚¤ãƒˆ
// http://www.asahi-net.or.jp/~ci5m-nmr/misc/holiday.html
// 2008/10/07 - ãƒã‚°ä¿®æ£
// version: 0.0.2
// ========================================================
Date.prototype.one_day_epoch = 1000 * 60 * 60 * 24;
Date.prototype.jp_hol_vernal_equinox_days = {
1925 : '3/21',
1926 : '3/21',
1927 : '3/21',
1928 : '3/21',
1929 : '3/21',
1930 : '3/21',
1931 : '3/21',
1932 : '3/21',
1933 : '3/21',
1934 : '3/21',
1935 : '3/21',
1936 : '3/21',
1937 : '3/21',
1938 : '3/21',
1939 : '3/21',
1940 : '3/21',
1941 : '3/21',
1942 : '3/21',
1943 : '3/21',
1944 : '3/21',
1945 : '3/21',
1946 : '3/21',
1947 : '3/21',
1948 : '3/21',
1949 : '3/21',
1950 : '3/21',
1951 : '3/21',
1952 : '3/21',
1953 : '3/21',
1954 : '3/21',
1955 : '3/21',
1956 : '3/21',
1957 : '3/21',
1958 : '3/21',
1959 : '3/21',
1960 : '3/20',
1961 : '3/21',
1962 : '3/21',
1963 : '3/21',
1964 : '3/20',
1965 : '3/21',
1966 : '3/21',
1967 : '3/21',
1968 : '3/20',
1969 : '3/21',
1970 : '3/21',
1971 : '3/21',
1972 : '3/20',
1973 : '3/21',
1974 : '3/21',
1975 : '3/21',
1976 : '3/20',
1977 : '3/21',
1978 : '3/21',
1979 : '3/21',
1980 : '3/20',
1981 : '3/21',
1982 : '3/21',
1983 : '3/21',
1984 : '3/20',
1985 : '3/21',
1986 : '3/21',
1987 : '3/21',
1988 : '3/20',
1989 : '3/21',
1990 : '3/21',
1991 : '3/21',
1992 : '3/20',
1993 : '3/20',
1994 : '3/21',
1995 : '3/21',
1996 : '3/20',
1997 : '3/20',
1998 : '3/21',
1999 : '3/21',
2000 : '3/20',
2001 : '3/20',
2002 : '3/21',
2003 : '3/21',
2004 : '3/20',
2005 : '3/20',
2006 : '3/21',
2007 : '3/21',
2008 : '3/20',
2009 : '3/20',
2010 : '3/21',
2011 : '3/21',
2012 : '3/20',
2013 : '3/20',
2014 : '3/21',
2015 : '3/21',
2016 : '3/20',
2017 : '3/20',
2018 : '3/21',
2019 : '3/20',
2020 : '3/20',
2021 : '3/20',
2022 : '3/21',
2023 : '3/21',
2024 : '3/20',
2025 : '3/20',
2026 : '3/20',
2027 : '3/21',
2028 : '3/20',
2029 : '3/20',
2030 : '3/20'
};
Date.prototype.jp_hol_autumnal_equinox_days = {
1925 : '9/23',
1926 : '9/24',
1927 : '9/24',
1928 : '9/23',
1929 : '9/23',
1930 : '9/24',
1931 : '9/24',
1932 : '9/23',
1933 : '9/23',
1934 : '9/24',
1935 : '9/24',
1936 : '9/23',
1937 : '9/23',
1938 : '9/24',
1939 : '9/24',
1940 : '9/23',
1941 : '9/23',
1942 : '9/24',
1943 : '9/24',
1944 : '9/23',
1945 : '9/23',
1946 : '9/24',
1947 : '9/24',
1948 : '9/23',
1949 : '9/23',
1950 : '9/23',
1951 : '9/24',
1952 : '9/23',
1953 : '9/23',
1954 : '9/23',
1955 : '9/24',
1956 : '9/23',
1957 : '9/23',
1958 : '9/23',
1959 : '9/24',
1960 : '9/23',
1961 : '9/23',
1962 : '9/23',
1963 : '9/24',
1964 : '9/23',
1965 : '9/23',
1966 : '9/23',
1967 : '9/24',
1968 : '9/23',
1969 : '9/23',
1970 : '9/23',
1971 : '9/24',
1972 : '9/23',
1973 : '9/23',
1974 : '9/23',
1975 : '9/24',
1976 : '9/23',
1977 : '9/23',
1978 : '9/23',
1979 : '9/24',
1980 : '9/23',
1981 : '9/23',
1982 : '9/23',
1983 : '9/23',
1984 : '9/23',
1985 : '9/23',
1986 : '9/23',
1987 : '9/23',
1988 : '9/23',
1989 : '9/23',
1990 : '9/23',
1991 : '9/23',
1992 : '9/23',
1993 : '9/23',
1994 : '9/23',
1995 : '9/23',
1996 : '9/23',
1997 : '9/23',
1998 : '9/23',
1999 : '9/23',
2000 : '9/23',
2001 : '9/23',
2002 : '9/23',
2003 : '9/23',
2004 : '9/23',
2005 : '9/23',
2006 : '9/23',
2007 : '9/23',
2008 : '9/23',
2009 : '9/23',
2010 : '9/23',
2011 : '9/23',
2012 : '9/22',
2013 : '9/23',
2014 : '9/23',
2015 : '9/23',
2016 : '9/22',
2017 : '9/23',
2018 : '9/23',
2019 : '9/23',
2020 : '9/22',
2021 : '9/23',
2022 : '9/23',
2023 : '9/23',
2024 : '9/22',
2025 : '9/23',
2026 : '9/23',
2027 : '9/23',
2028 : '9/22',
2029 : '9/23',
2030 : '9/23'
};
Date.prototype.getJpHolNationalFoundationDay = function (y) {
return 1967 <= y ? '2/11' : null;
}
Date.prototype.getJpHolEquinoxDateCalc = function (y, va) {
// 1太陽年ã¯ï¼ˆè¥¿æš¦2000å¹´ã«ãŠã„ã¦ï¼‰365.24219日(365.24219040日)ã¨ãªã£ã¦ãŠã‚Šã€100å¹´é–“ã§ç´„0.53ç§’ãšã¤çŸããªã£ã¦ã„る。
// 2000å¹´ã®å¤ªé™½ã®æ˜¥åˆ†ç‚¹é€šéŽæ—¥
// 3月20.69115日
// 2000å¹´ã®å¤ªé™½ã®ç§‹åˆ†ç‚¹é€šéŽæ—¥
// 9月23.09日
var equinox;
switch(va) {
case 'vernal':
// date('2000/03/20').getTime() + (60 * 60 * 24 * 0.69115)
equinox = 953537715.36;
break;
case 'autumnal':
// date('2000-09-23').getTime() + (60 * 60 * 24 * 0.09)
equinox = 969642576.00;
break;
}
// 2000å¹´ã®æ˜¥(ç§‹)分点 + 2000å¹´ã‹ã‚‰å¤ªé™½å¹´ã®è¨ˆç®— + 太陽年ã®èª¤å·®ä¿®æ£ï¼ˆ100å¹´é–“ã§ç´„0.53çŸããªã‚Šã¤ã¤ã‚る)
var i;
var y_sum = 0;
for(i = 0; i > y - 2000; i--) {
y_sum += i;
}
for(i = 0; i < y - 2000; i++) {
y_sum += i;
}
// var target_date_equinox = new Date(equinox + (3155692525056 * (y - 2000) / 100000) + (53 * (array_sum(range(0, y - 2000))) / 10000));
var target_date_equinox = new Date((equinox + (3155692525056 * (y - 2000) / 100000) + (53 * y_sum / 10000)) * 1000);
return (target_date_equinox.getMonth() + 1) + '/' + target_date_equinox.getDate();
}
Date.prototype.isJpHolVernalEquinoxDay = function (y, m_d) {
var ve_m_d;
if(this.jp_hol_vernal_equinox_days[y]) {
ve_m_d = this.jp_hol_vernal_equinox_days[y];
} else {
ve_m_d = this.getJpHolEquinoxDateCalc(y, 'vernal');
this.jp_hol_vernal_equinox_days[y] = ve_m_d;
}
return m_d == ve_m_d ? true : false;
}
Date.prototype.isJpHolAutumnalEquinoxDay = function (y, m_d) {
// return m_d == (this.jp_hol_autumnal_equinox_days[y] ? this.jp_hol_autumnal_equinox_days[y] : this.getJpHolEquinoxDateCalc(y, 'autumnal'));
var va_m_d;
if(this.jp_hol_autumnal_equinox_days[y]) {
va_m_d = this.jp_hol_autumnal_equinox_days[y];
} else {
va_m_d = this.getJpHolEquinoxDateCalc(y, 'autumnal');
this.jp_hol_autumnal_equinox_days[y] = va_m_d;
}
return m_d == va_m_d ? true : false;
}
Date.prototype.isJpHoliday = function(by_date_itself) {
var y = this.getFullYear();
var m_d = (this.getMonth() + 1) + '/' + this.getDate();
var y_m_d = y + '/' + m_d; // 2008-10-07 è¿½åŠ ãƒã‚°ä¿®æ£ã”ã‚ã‚“
var national_foundation_m_d = this.getJpHolNationalFoundationDay(y);
if(this.is_jp_holiday && typeof(this.is_jp_holiday) == 'boolean' && this.y_m_d && this.y_m_d == y_m_d) {
return this.is_jp_holiday;
}
this.y_m_d = y_m_d;
switch(m_d) {
case '1/1':
if(1949 <= y) {
this.jp_hol_name = '元日';
this.jp_hol_engl = 'New Year\'s Day';
this.jp_hol_desc = 'å¹´ã®ã¯ã˜ã‚ã‚’ç¥ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '1/15':
if(1949 <= y && y <= 1999) {
this.jp_hol_name = 'æˆäººã®æ—¥';
this.jp_hol_engl = 'Coming of Age Day';
this.jp_hol_desc = 'ãŠã¨ãªã«ãªã£ãŸã“ã¨ã‚’自覚ã—ã€ã¿ãšã‹ã‚‰ç”Ÿã抜ã“ã†ã¨ã™ã‚‹é’å¹´ã‚’ç¥ã„ã¯ã’ã¾ã™ã€‚';
this.is_jp_holiday = true;
return true; // 2008-10-07 è¿½åŠ ãƒã‚°ä¿®æ£ã”ã‚ã‚“
}
break;
case '4/29':
if(1927 <= y && y <= 1988) {
this.jp_hol_name = '天皇誕生日';
this.jp_hol_engl = 'Emperor\'s Birthday';
this.jp_hol_desc = '天皇ã®èª•生日をç¥ã†ã€‚';
this.is_jp_holiday = true;
return true;
} else if(1989 <= y && y <= 2006) {
this.jp_hol_name = 'ã¿ã©ã‚Šã®æ—¥';
this.jp_hol_engl = 'Greenery Day';
this.jp_hol_desc = '自然ã«è¦ªã—ã‚€ã¨ã¨ã‚‚ã«ãã®æ©æµã«æ„Ÿè¬ã—ã€è±Šã‹ãªå¿ƒã‚’ã¯ããむ。';
this.is_jp_holiday = true;
return true;
} else if(2007 <= y) {
this.jp_hol_name = 'æ˜å’Œã®æ—¥';
this.jp_hol_engl = 'Showa Day'; // æ£å¼ãªç™ºè¡¨ã§ã¯ã‚りã¾ã›ã‚“…
this.jp_hol_desc = 'æ¿€å‹•ã®æ—¥ã€…を経ã¦ã€å¾©èˆˆã‚’é‚ã’ãŸæ˜å’Œã®æ™‚代を顧ã¿ã€å›½ã®å°†æ¥ã«æ€ã„ã‚’ã„ãŸã™ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '5/3':
if(1949 <= y) {
this.jp_hol_name = '憲法記念日';
this.jp_hol_engl = 'Constitution Memorial Day';
this.jp_hol_desc = 'æ—¥æœ¬å›½æ†²æ³•ã®æ–½è¡Œã‚’記念ã—ã€å›½ã®æˆé•·ã‚’期ã™ã‚‹ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '5/4':
if(2007 <= y) {
this.jp_hol_name = 'ã¿ã©ã‚Šã®æ—¥';
this.jp_hol_engl = 'Greenery Day';
this.jp_hol_desc = '自然ã«è¦ªã—ã‚€ã¨ã¨ã‚‚ã«ãã®æ©æµã«æ„Ÿè¬ã—ã€è±Šã‹ãªå¿ƒã‚’ã¯ããむ。';
this.is_jp_holiday = true;
return true;
}
break;
case '5/5':
if(1949 <= y) {
this.jp_hol_name = 'ã“ã©ã‚‚ã®æ—¥';
this.jp_hol_engl = 'Children\'s Day';
this.jp_hol_desc = 'ã“ã©ã‚‚ã®äººæ ¼ã‚’é‡ã‚“ã˜ã€ã“ã©ã‚‚ã®å¹¸ç¦ã‚’ã¯ã‹ã‚‹ã¨ã¨ã‚‚ã«ã€æ¯ã«æ„Ÿè¬ã™ã‚‹ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '7/20':
if(1996 <= y && y <= 2002) {
this.jp_hol_name = 'æµ·ã®æ—¥';
this.jp_hol_engl = 'Marine Day';
this.jp_hol_desc = 'æµ·ã®æ©æµã«æ„Ÿè¬ã™ã‚‹ã¨ã¨ã‚‚ã«ã€æµ·æ´‹å›½æ—¥æœ¬ã®ç¹æ „を願ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '9/15':
if(1967 <= y && y <= 2002) {
this.jp_hol_name = '敬è€ã®æ—¥';
this.jp_hol_engl = 'Respect for the Aged Day';
this.jp_hol_desc = '多年ã«ã‚ãŸã‚Šç¤¾ä¼šã«ã¤ãã—ã¦ããŸè€äººã‚’敬愛ã—ã€é•·å¯¿ã‚’ç¥ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '10/10':
if(1966 <= y && y <= 1999) {
this.jp_hol_name = 'ä½“è‚²ã®æ—¥';
this.jp_hol_engl = 'Health and Sports Day';
this.jp_hol_desc = 'スãƒãƒ¼ãƒ„ã«ã—ãŸã—ã¿ã€å¥åº·ãªå¿ƒèº«ã‚’ã¤ã¡ã‹ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '11/3':
if(1948 <= y) {
this.jp_hol_name = 'æ–‡åŒ–ã®æ—¥';
this.jp_hol_engl = 'National Culture Day';
this.jp_hol_desc = '自由ã¨å¹³å’Œã‚’æ„›ã—ã€æ–‡åŒ–ã‚’ã™ã™ã‚る。';
this.is_jp_holiday = true;
return true;
}
break;
case '11/23':
if(1948 <= y) {
this.jp_hol_name = '勤労感è¬ã®æ—¥';
this.jp_hol_engl = 'Labor Thanksgiving Day';
this.jp_hol_desc = '勤労をãŸã£ã¨ã³ã€ç”Ÿç”£ã‚’ç¥ã„ã€å›½æ°‘ãŸãŒã„ã«æ„Ÿè¬ã—ã‚ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '12/23':
if(1989 <= y) {
this.jp_hol_name = '天皇誕生日';
this.jp_hol_engl = 'Emperor\'s Birthday';
this.jp_hol_desc = '天皇ã®èª•生日をç¥ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '2/11': // 政令ã§å®šã‚ã‚‹æ—¥
if(1967 <= y) {
this.jp_hol_name = 'å»ºå›½è¨˜å¿µã®æ—¥';
this.jp_hol_engl = 'National Foundation Day';
this.jp_hol_desc = '建国をã—ã®ã³ã€å›½ã‚’æ„›ã™ã‚‹å¿ƒã‚’養ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
}
switch((this.getMonth() + 1) + '-' + Math.ceil(this.getDate() / 7) + '-' + this.getDay()) {
case '1-2-1': // 1月ã®ç¬¬ï¼’月曜日
if(2000 <= y) {
this.jp_hol_name = 'æˆäººã®æ—¥';
this.jp_hol_engl = 'Coming of Age Day';
this.jp_hol_desc = 'ãŠã¨ãªã«ãªã£ãŸã“ã¨ã‚’自覚ã—ã€ã¿ãšã‹ã‚‰ç”Ÿã抜ã“ã†ã¨ã™ã‚‹é’å¹´ã‚’ç¥ã„ã¯ã’ã¾ã™ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '7-3-1': // 7月ã®ç¬¬ï¼“月曜日
if(2003 <= y) {
this.jp_hol_name = 'æµ·ã®æ—¥';
this.jp_hol_engl = 'Marine Day';
this.jp_hol_desc = 'æµ·ã®æ©æµã«æ„Ÿè¬ã™ã‚‹ã¨ã¨ã‚‚ã«ã€æµ·æ´‹å›½æ—¥æœ¬ã®ç¹æ „を願ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '9-3-1': // 9月ã®ç¬¬ï¼“月曜日
if(2003 <= y) {
this.jp_hol_name = '敬è€ã®æ—¥';
this.jp_hol_engl = 'Respect for the Aged Day';
this.jp_hol_desc = '多年ã«ã‚ãŸã‚Šç¤¾ä¼šã«ã¤ãã—ã¦ããŸè€äººã‚’敬愛ã—ã€é•·å¯¿ã‚’ç¥ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
case '10-2-1': // ï¼‘ï¼æœˆã®ç¬¬ï¼’月曜日
if(2000 <= y) {
this.jp_hol_name = 'ä½“è‚²ã®æ—¥';
this.jp_hol_engl = 'Health and Sports Day';
this.jp_hol_desc = 'スãƒãƒ¼ãƒ„ã«ã—ãŸã—ã¿ã€å¥åº·ãªå¿ƒèº«ã‚’ã¤ã¡ã‹ã†ã€‚';
this.is_jp_holiday = true;
return true;
}
break;
}
if(this.isJpHolVernalEquinoxDay(y, m_d)) {
if(1949 <= y) {
this.jp_hol_name = 'æ˜¥åˆ†ã®æ—¥';
this.jp_hol_engl = 'Vernal Equinox';
this.jp_hol_desc = '自然をãŸãŸãˆã€ç”Ÿç‰©ã‚’ã„ã¤ãã—む。';
this.is_jp_holiday = true;
return true;
}
}
if(this.isJpHolAutumnalEquinoxDay(y, m_d)) {
if(1948 <= y) {
this.jp_hol_name = 'ç§‹åˆ†ã®æ—¥';
this.jp_hol_engl = 'Autumnal Equinox';
this.jp_hol_desc = '祖先をã†ã‚„ã¾ã„ã€ãªããªã£ãŸäººã€…ã‚’ã—ã®ã¶ã€‚';
this.is_jp_holiday = true;
return true;
}
}
if(by_date_itself) {
this.jp_hol_name = null;
this.jp_hol_engl = null;
this.jp_hol_desc = null;
this.is_jp_holiday = false;
return false;
}
var date_before = new Date(this.getTime() - this.one_day_epoch);
if(date_before.isJpHoliday(true)) { // 剿—¥ãŒç¥æ—¥
if(date_before.getDay() == 0) { // 剿—¥ãŒç¥æ—¥ã‹ã¤æ—¥æ›œãªã‚‰ã°
this.jp_hol_name = '振替休日';
this.jp_hol_engl = 'Substitute Holiday';
this.jp_hol_desc = null;
this.is_jp_holiday = true;
return true;
}
if(1986 <= y) {
var date_after = new Date(this.getTime() + this.one_day_epoch);
if(date_after.isJpHoliday(true)) { // 剿—¥ã‚‚ç¿Œæ—¥ã‚‚ç¥æ—¥ãªã‚‰ã°
this.jp_hol_name = '国民ã®ä¼‘æ—¥';
this.jp_hol_engl = 'Holiday for a Nation';
this.jp_hol_desc = null;
this.is_jp_holiday = true;
return true;
}
}
if(2007 <= y) {
date_before.setTime(date_before.getTime() - this.one_day_epoch);
while(date_before.isJpHoliday(true)) { // 剿—¥ä»¥å‰ãŒç¥æ—¥ã®é€£ç¶šã«ãªã£ã¦ã„ã‚‹å ´åˆ
if(date_before.getDay() == 0) { // 剿—¥ä»¥å‰ãŒç¥æ—¥ã®é€£ç¶šã§ã€æ—¥æ›œãŒé‡ãªã‚‹å ´åˆ
this.jp_hol_name = '振替休日';
this.jp_hol_engl = 'Substitute Holiday';
this.jp_hol_desc = null;
this.is_jp_holiday = true;
return true;
}
date_before.setTime(date_before.getTime() - this.one_day_epoch);
}
}
}
this.jp_hol_name = null;
this.jp_hol_engl = null;
this.jp_hol_desc = null;
this.is_jp_holiday = false;
return false;
}