2019年4月8日(月)~5月1日(水)
[JavaScript] 令和に対応 #■パソコン・通信 日付JavaScriptライブラリを、『令和』に対応しました。
https://neconote.jp/prg/date.jsテキストエンコード:Unicode(UTF-8)
【date.jsライブラリ】
1.変数と関数
■日付変数
$week[n]
曜日配列。n=0~6
■元号の日付オブジェクト
$meiji, $meiji1
明治元年1月1日[旧暦]
(1868年1月25日)
$meiji2
明治2年1月1日[旧暦]
(1869年2月11日)
$meiji3
明治3年1月1日[旧暦]
(1870年2月1日)
$meiji4
明治4年1月1日[旧暦]
(1871年2月19日)
$meiji5
明治5年1月1日[旧暦]
(1872年2月9日)
$meiji6
明治6年1月1日[太陽暦]
$taisho
明治45年7月30日
大正元年7月30日
$showa
大正15年12月25日
昭和元年12月25日
$heisei
平成元年1月8日
$reiwa
令和元年5月1日
■日付関数
○年月日の校正
_true_date($year,$month,$date)
※$month:1~12
・グローバル変数 $y,$m,$d,$w
○元号
_gengo($year,$month[,$date])
※$month:1~12
・月単位の場合
・グローバル変数 $gengo,$start_w,$days
・日単位の場合
・グローバル変数 $gengo
・返り値 $gengo
○祝日の判定
_holiday($year,$month,$date)
※$month:1~12
・グローバル変数 $holiday,$w
・返り値 true/false
■月カレンダー表示の関数
○月カレンダーの初期設定
_setup_calendar()
○月カレンダーの表示
_calendar($year,$month)
○表示月の変更
_month_btn(n)
・nは、月の増減値
2.月カレンダーを表示する場合
(1) HTMLファイルの<body></body>において、下記を参考に記述して下さい。
<body>
<div id="id_calendar"></div>
</body>
(2) HTMLファイルの<style></style>と<script></script>において、下記を参考に記述して下さい。
<head>
<style>
td {text-align:center;}
.sun {color:red;}
.sat {color:blue;}
.today{background:gold;}
</style>
<script src="date.js"></script>
<script>
window.onload = _setup_calendar;
</script>
</head>
(3) 例
https://neconote.jp/prg/calendar.html