七十二候表示 JavaScript — 俳句愛好家のための

今日は魚氷に上がる立春末候。

白井明大・著,有賀一広・画『日本の七十二候を楽しむ』(東邦出版,2012年刊)は,ときおり取り出してそのときの季節感を確認する愛読書になっている。三年ほど前に妻から誕生日プレゼントとして貰った本である。昔の日本人は必ず暦を買い求めてその日その日の位置づけを確認していたようである。永井荷風の『断腸亭日乗』にも,「年の瀬になったので来年の暦を買わなくては」のようなことを書いているところがあったはずである(どこだったかは思い出せず)。荷風はこれで二十四節気,月相を判断していたようである。

かような次第で,今日が日本の伝統的季のどの節目にあたるのかを教えてくれるツールが欲しくなった。ちょうど今日は立春末候であり,伝統的七十二候解説では「魚氷に上がる」候 — このように,その日の七十二候の名称と解説句を教えてくれるツール。暦に関してさまざまな啓蒙的情報を公開している「こよみのページ」の「七十二候の日付計算」ページから取得した計算結果 CSV をもとに,Web 七十二候表示アクセサリー JavaScript を書いた。いまごらんのページ右の Moon Calendar の下に出ているものである。日本の七十二候を楽しむ方,そして,俳句を詠む方にとって役に立つと幸いである。

こよみのページ」に,「七十二候の日付の計算は定気法により,地球中心における太陽の視黄経を 5°毎(0~355)に区切り,これを通過する日本標準時の日付として計算しました」とある通り,立春,立夏等の七十二候の開始終了日付はいつも同じではなく,正確には年によって変動する。たとえば,二十四節気「立冬」の開始日は,2000 年から 2031 年においては,年を 4 除算した剰余によって,0: 11/7,1: 11/7,2: 11/7,3: 11/8 と日が違う。今年 2015 年は剰余 3 の 11/8 である(来年は 4 で割り切れるので剰余 0 の 11/7)。七十二候の初候,次候,末候も開始日が変わって来る。暦というものは専門家による暦法計算に基づくわけである。

定気法に基づいて太陽視黄経計算を行うのは素人の私にはたいへん面倒なので,「こよみのページ」提供 CSV データを 2015 年から 2020 年までダウンロードし,Perl プログラムを書いてこれを JavaScript JSON 配列データに加工して JavaScript に仕立て上げることにした(この Perl ツールについては割愛する)。

以下にその完全な JavaScript コードを掲載しておく。2015-2020 の期間については,その日の七十二候を正確に判定して表示できるはずである。2021 年以降はテーブルを追加すればよいのだが,とりあえず年の mod 4 を求めて,0: 2020 年,1: 2017 年,2: 2018 年,3: 2019 年の配列データで代替する論理にしてある。

jQuery JavaScript ライブラリとの併用を前提としている。Web ページの本日の七十二候を表示したいところに <div id="koyomi_72ko"></div> としるしておく。ページをロードした年月日,七十二候名称及び七十二候解説句が表示される。七十二候解説句は角川書店『合本 俳句歳時記 第三版』(1997 年刊)に準拠した(ただし,文字は misima を用いて旧字体にしてある)。そして七十二候解説句にカーソルを当てると解説の読みがポップアップされるようにしてある。表示項目はそれぞれ ko-dateko-nameko-kaisetsu のスタイルクラスが設定されているので,スタイルシートで表示の仕方を工夫すればよい。(*)

(*) ちなみに弊サイトでは ko-date クラスに対し,display: none; としているので,現在の年月日は表示されない。

"年月" をキーとする長大な配列は,Perl プログラムで「こよみのページ」CSV を加工して埋め込んだものである。芸がないが,ま,いいでしょう。

// -*- coding: utf-8; mode: javascript; -*-
// 七十二候表示 - ko72.js
// - 日付データからその日の七十二候を特定して候とその解説句を表示する
// - 日付と七十二候の対応は年により異なるため,年に応じたテーブルを用いる
// - 対象年のテーブルがなければ 4 の剰余で代用する
// - 出力例: 20150407 --> "清明・初候 玄鳥至(つばめいたる)"
// - 七十二候データは,「こよみのページ」http://koyomi.vis.ne.jp/ から取得した
//   2015-2020 の七十二候開始日 CSV である
// 2015(c) isao yasuda
// $Id: ko72.js 53 2015-02-08 09:19:25Z isao $
 
$(function() {
    // 現在時を取得
    var curdate = new Date();
    var cyear = curdate.getFullYear();   // 年
    var cmonth = curdate.getMonth() + 1; // 月
    var cday = curdate.getDate();        // 日
    // 七十二候名称を取得
    var ko_name = getkoname(cyear, cmonth, cday);
    // 七十二候の解説句とその読みを取得
    var ko_kaisetsu = getkokaisetsu(ko_name);
    // ページに挿入
    $("#koyomi_72ko").html(
        '<span class="ko-date">' + 
            cyear + '年' + cmonth + '月' + cday + '日' + '</span>' + // 日付
            '<span class="ko-name">' + ko_name + '</span>' + // 七十二候名称
            '<span class="ko-kaisetsu" ' +
            'title="' + ko_kaisetsu.yomi + '">' + // 七十二候解説句読み
            ko_kaisetsu.kai + '</span>'           // 七十二候解説句
    );
});
 
// 七十二候名称取得
function getkoname(cyear, cmonth, cday) {
    var kotbl = new Array(); // 月の候配列
    // 年月文字列をキーとする日と七十二候対応テーブル
    // - KOARRAYINCLUDE 部にプログラムで埋め込む
    // - 毎月 1 日の候のデータを要素に加えること(年月でブレークしたら前レコードの候を選択) 
    /* 七十二候対応テーブルのフォーマット
    kotbl["201504"] = [
        { "day": 01, "ko": "春分・末侯" }, // ブレーク前の七十二候をセットしておく
        { "day": 05, "ko": "清明・初侯" }, // (01 から始まる七十二候がない場合のみ)
        { "day": 10, "ko": "清明・次侯" },
        { "day": 15, "ko": "清明・末侯" },
        { "day": 20, "ko": "穀雨・初侯" },
        { "day": 25, "ko": "穀雨・次侯" }
    ];
    */
    //$KOARRAYINCLUDE
    kotbl["201501"]=[{"day":01,"ko":"冬至・末侯"},{"day":06,"ko":"小寒・初侯"},
                     {"day":10,"ko":"小寒・次侯"},{"day":15,"ko":"小寒・末侯"},
                     {"day":20,"ko":"大寒・初侯"},{"day":25,"ko":"大寒・次侯"},
                     {"day":30,"ko":"大寒・末侯"}];
    kotbl["201502"]=[{"day":01,"ko":"大寒・末侯"},{"day":04,"ko":"立春・初侯"},
                     {"day":09,"ko":"立春・次侯"},{"day":14,"ko":"立春・末侯"},
                     {"day":19,"ko":"雨水・初侯"},{"day":24,"ko":"雨水・次侯"}];
    kotbl["201503"]=[{"day":01,"ko":"雨水・末侯"},{"day":06,"ko":"啓蟄・初侯"},
                     {"day":11,"ko":"啓蟄・次侯"},{"day":16,"ko":"啓蟄・末侯"},
                     {"day":21,"ko":"春分・初侯"},{"day":26,"ko":"春分・次侯"},
                     {"day":31,"ko":"春分・末侯"}];
    kotbl["201504"]=[{"day":01,"ko":"春分・末侯"},{"day":05,"ko":"清明・初侯"},
                     {"day":10,"ko":"清明・次侯"},{"day":15,"ko":"清明・末侯"},
                     {"day":20,"ko":"穀雨・初侯"},{"day":25,"ko":"穀雨・次侯"}];
    kotbl["201505"]=[{"day":01,"ko":"穀雨・末侯"},{"day":06,"ko":"立夏・初侯"},
                     {"day":11,"ko":"立夏・次侯"},{"day":16,"ko":"立夏・末侯"},
                     {"day":21,"ko":"小満・初侯"},{"day":26,"ko":"小満・次侯"}];
    kotbl["201506"]=[{"day":01,"ko":"小満・末侯"},{"day":06,"ko":"芒種・初侯"},
                     {"day":11,"ko":"芒種・次侯"},{"day":16,"ko":"芒種・末侯"},
                     {"day":22,"ko":"夏至・初侯"},{"day":27,"ko":"夏至・次侯"}];
    kotbl["201507"]=[{"day":01,"ko":"夏至・次侯"},{"day":02,"ko":"夏至・末侯"},
                     {"day":07,"ko":"小暑・初侯"},{"day":13,"ko":"小暑・次侯"},
                     {"day":18,"ko":"小暑・末侯"},{"day":23,"ko":"大暑・初侯"},
                     {"day":28,"ko":"大暑・次侯"}];
    kotbl["201508"]=[{"day":01,"ko":"大暑・次侯"},{"day":02,"ko":"大暑・末侯"},
                     {"day":08,"ko":"立秋・初侯"},{"day":13,"ko":"立秋・次侯"},
                     {"day":18,"ko":"立秋・末侯"},{"day":23,"ko":"処暑・初侯"},
                     {"day":29,"ko":"処暑・次侯"}];
    kotbl["201509"]=[{"day":01,"ko":"処暑・次侯"},{"day":03,"ko":"処暑・末侯"},
                     {"day":08,"ko":"白露・初侯"},{"day":13,"ko":"白露・次侯"},
                     {"day":18,"ko":"白露・末侯"},{"day":23,"ko":"秋分・初侯"},
                     {"day":28,"ko":"秋分・次侯"}];
    kotbl["201510"]=[{"day":01,"ko":"秋分・次侯"},{"day":03,"ko":"秋分・末侯"},
                     {"day":08,"ko":"寒露・初侯"},{"day":14,"ko":"寒露・次侯"},
                     {"day":19,"ko":"寒露・末侯"},{"day":24,"ko":"霜降・初侯"},
                     {"day":29,"ko":"霜降・次侯"}];
    kotbl["201511"]=[{"day":01,"ko":"霜降・次侯"},{"day":03,"ko":"霜降・末侯"},
                     {"day":08,"ko":"立冬・初侯"},{"day":13,"ko":"立冬・次侯"},
                     {"day":18,"ko":"立冬・末侯"},{"day":23,"ko":"小雪・初侯"},
                     {"day":27,"ko":"小雪・次侯"}];
    kotbl["201512"]=[{"day":01,"ko":"小雪・次侯"},{"day":02,"ko":"小雪・末侯"},
                     {"day":07,"ko":"大雪・初侯"},{"day":12,"ko":"大雪・次侯"},
                     {"day":17,"ko":"大雪・末侯"},{"day":22,"ko":"冬至・初侯"},
                     {"day":27,"ko":"冬至・次侯"}];
    kotbl["201601"]=[{"day":01,"ko":"冬至・末侯"},{"day":06,"ko":"小寒・初侯"},
                     {"day":11,"ko":"小寒・次侯"},{"day":16,"ko":"小寒・末侯"},
                     {"day":21,"ko":"大寒・初侯"},{"day":25,"ko":"大寒・次侯"},
                     {"day":30,"ko":"大寒・末侯"}];
    kotbl["201602"]=[{"day":01,"ko":"大寒・末侯"},{"day":04,"ko":"立春・初侯"},
                     {"day":09,"ko":"立春・次侯"},{"day":14,"ko":"立春・末侯"},
                     {"day":19,"ko":"雨水・初侯"},{"day":24,"ko":"雨水・次侯"},
                     {"day":29,"ko":"雨水・末侯"}];
    kotbl["201603"]=[{"day":01,"ko":"雨水・末侯"},{"day":05,"ko":"啓蟄・初侯"},
                     {"day":10,"ko":"啓蟄・次侯"},{"day":15,"ko":"啓蟄・末侯"},
                     {"day":20,"ko":"春分・初侯"},{"day":25,"ko":"春分・次侯"},
                     {"day":30,"ko":"春分・末侯"}];
    kotbl["201604"]=[{"day":01,"ko":"春分・末侯"},{"day":04,"ko":"清明・初侯"},
                     {"day":09,"ko":"清明・次侯"},{"day":14,"ko":"清明・末侯"},
                     {"day":20,"ko":"穀雨・初侯"},{"day":25,"ko":"穀雨・次侯"},
                     {"day":30,"ko":"穀雨・末侯"}];
    kotbl["201605"]=[{"day":01,"ko":"穀雨・末侯"},{"day":05,"ko":"立夏・初侯"},
                     {"day":10,"ko":"立夏・次侯"},{"day":15,"ko":"立夏・末侯"},
                     {"day":20,"ko":"小満・初侯"},{"day":26,"ko":"小満・次侯"},
                     {"day":31,"ko":"小満・末侯"}];
    kotbl["201606"]=[{"day":01,"ko":"小満・末侯"},{"day":05,"ko":"芒種・初侯"},
                     {"day":10,"ko":"芒種・次侯"},{"day":16,"ko":"芒種・末侯"},
                     {"day":21,"ko":"夏至・初侯"},{"day":26,"ko":"夏至・次侯"}];
    kotbl["201607"]=[{"day":01,"ko":"夏至・末侯"},{"day":07,"ko":"小暑・初侯"},
                     {"day":12,"ko":"小暑・次侯"},{"day":17,"ko":"小暑・末侯"},
                     {"day":22,"ko":"大暑・初侯"},{"day":28,"ko":"大暑・次侯"}];
    kotbl["201608"]=[{"day":01,"ko":"大暑・次侯"},{"day":02,"ko":"大暑・末侯"},
                     {"day":07,"ko":"立秋・初侯"},{"day":12,"ko":"立秋・次侯"},
                     {"day":17,"ko":"立秋・末侯"},{"day":23,"ko":"処暑・初侯"},
                     {"day":28,"ko":"処暑・次侯"}];
    kotbl["201609"]=[{"day":01,"ko":"処暑・次侯"},{"day":02,"ko":"処暑・末侯"},
                     {"day":07,"ko":"白露・初侯"},{"day":12,"ko":"白露・次侯"},
                     {"day":17,"ko":"白露・末侯"},{"day":22,"ko":"秋分・初侯"},
                     {"day":28,"ko":"秋分・次侯"}];
    kotbl["201610"]=[{"day":01,"ko":"秋分・次侯"},{"day":03,"ko":"秋分・末侯"},
                     {"day":08,"ko":"寒露・初侯"},{"day":13,"ko":"寒露・次侯"},
                     {"day":18,"ko":"寒露・末侯"},{"day":23,"ko":"霜降・初侯"},
                     {"day":28,"ko":"霜降・次侯"}];
    kotbl["201611"]=[{"day":01,"ko":"霜降・次侯"},{"day":02,"ko":"霜降・末侯"},
                     {"day":07,"ko":"立冬・初侯"},{"day":12,"ko":"立冬・次侯"},
                     {"day":17,"ko":"立冬・末侯"},{"day":22,"ko":"小雪・初侯"},
                     {"day":27,"ko":"小雪・次侯"}];
    kotbl["201612"]=[{"day":01,"ko":"小雪・次侯"},{"day":02,"ko":"小雪・末侯"},
                     {"day":07,"ko":"大雪・初侯"},{"day":11,"ko":"大雪・次侯"},
                     {"day":16,"ko":"大雪・末侯"},{"day":21,"ko":"冬至・初侯"},
                     {"day":26,"ko":"冬至・次侯"},{"day":31,"ko":"冬至・末侯"}];
    kotbl["201701"]=[{"day":01,"ko":"冬至・末侯"},{"day":05,"ko":"小寒・初侯"},
                     {"day":10,"ko":"小寒・次侯"},{"day":15,"ko":"小寒・末侯"},
                     {"day":20,"ko":"大寒・初侯"},{"day":25,"ko":"大寒・次侯"},
                     {"day":30,"ko":"大寒・末侯"}];
    kotbl["201702"]=[{"day":01,"ko":"大寒・末侯"},{"day":04,"ko":"立春・初侯"},
                     {"day":08,"ko":"立春・次侯"},{"day":13,"ko":"立春・末侯"},
                     {"day":18,"ko":"雨水・初侯"},{"day":23,"ko":"雨水・次侯"},
                     {"day":28,"ko":"雨水・末侯"}];
    kotbl["201703"]=[{"day":01,"ko":"雨水・末侯"},{"day":05,"ko":"啓蟄・初侯"},
                     {"day":10,"ko":"啓蟄・次侯"},{"day":15,"ko":"啓蟄・末侯"},
                     {"day":20,"ko":"春分・初侯"},{"day":25,"ko":"春分・次侯"},
                     {"day":30,"ko":"春分・末侯"}];
    kotbl["201704"]=[{"day":01,"ko":"春分・末侯"},{"day":04,"ko":"清明・初侯"},
                     {"day":10,"ko":"清明・次侯"},{"day":15,"ko":"清明・末侯"},
                     {"day":20,"ko":"穀雨・初侯"},{"day":25,"ko":"穀雨・次侯"},
                     {"day":30,"ko":"穀雨・末侯"}];
    kotbl["201705"]=[{"day":01,"ko":"穀雨・末侯"},{"day":05,"ko":"立夏・初侯"},
                     {"day":10,"ko":"立夏・次侯"},{"day":16,"ko":"立夏・末侯"},
                     {"day":21,"ko":"小満・初侯"},{"day":26,"ko":"小満・次侯"},
                     {"day":31,"ko":"小満・末侯"}];
    kotbl["201706"]=[{"day":01,"ko":"小満・末侯"},{"day":05,"ko":"芒種・初侯"},
                     {"day":11,"ko":"芒種・次侯"},{"day":16,"ko":"芒種・末侯"},
                     {"day":21,"ko":"夏至・初侯"},{"day":26,"ko":"夏至・次侯"}];
    kotbl["201707"]=[{"day":01,"ko":"夏至・次侯"},{"day":02,"ko":"夏至・末侯"},
                     {"day":07,"ko":"小暑・初侯"},{"day":12,"ko":"小暑・次侯"},
                     {"day":17,"ko":"小暑・末侯"},{"day":23,"ko":"大暑・初侯"},
                     {"day":28,"ko":"大暑・次侯"}];
    kotbl["201708"]=[{"day":01,"ko":"大暑・次侯"},{"day":02,"ko":"大暑・末侯"},
                     {"day":07,"ko":"立秋・初侯"},{"day":12,"ko":"立秋・次侯"},
                     {"day":18,"ko":"立秋・末侯"},{"day":23,"ko":"処暑・初侯"},
                     {"day":28,"ko":"処暑・次侯"}];
    kotbl["201709"]=[{"day":01,"ko":"処暑・次侯"},{"day":02,"ko":"処暑・末侯"},
                     {"day":07,"ko":"白露・初侯"},{"day":12,"ko":"白露・次侯"},
                     {"day":18,"ko":"白露・末侯"},{"day":23,"ko":"秋分・初侯"},
                     {"day":28,"ko":"秋分・次侯"}];
    kotbl["201710"]=[{"day":01,"ko":"秋分・次侯"},{"day":03,"ko":"秋分・末侯"},
                     {"day":08,"ko":"寒露・初侯"},{"day":13,"ko":"寒露・次侯"},
                     {"day":18,"ko":"寒露・末侯"},{"day":23,"ko":"霜降・初侯"},
                     {"day":28,"ko":"霜降・次侯"}];
    kotbl["201711"]=[{"day":01,"ko":"霜降・次侯"},{"day":02,"ko":"霜降・末侯"},
                     {"day":07,"ko":"立冬・初侯"},{"day":12,"ko":"立冬・次侯"},
                     {"day":17,"ko":"立冬・末侯"},{"day":22,"ko":"小雪・初侯"},
                     {"day":27,"ko":"小雪・次侯"}];
    kotbl["201712"]=[{"day":01,"ko":"小雪・次侯"},{"day":02,"ko":"小雪・末侯"},
                     {"day":07,"ko":"大雪・初侯"},{"day":12,"ko":"大雪・次侯"},
                     {"day":17,"ko":"大雪・末侯"},{"day":22,"ko":"冬至・初侯"},
                     {"day":26,"ko":"冬至・次侯"},{"day":31,"ko":"冬至・末侯"}];
    kotbl["201801"]=[{"day":01,"ko":"冬至・末侯"},{"day":05,"ko":"小寒・初侯"},
                     {"day":10,"ko":"小寒・次侯"},{"day":15,"ko":"小寒・末侯"},
                     {"day":20,"ko":"大寒・初侯"},{"day":25,"ko":"大寒・次侯"},
                     {"day":30,"ko":"大寒・末侯"}];
    kotbl["201802"]=[{"day":01,"ko":"大寒・末侯"},{"day":04,"ko":"立春・初侯"},
                     {"day":09,"ko":"立春・次侯"},{"day":14,"ko":"立春・末侯"},
                     {"day":19,"ko":"雨水・初侯"},{"day":24,"ko":"雨水・次侯"}];
    kotbl["201803"]=[{"day":01,"ko":"雨水・末侯"},{"day":06,"ko":"啓蟄・初侯"},
                     {"day":11,"ko":"啓蟄・次侯"},{"day":16,"ko":"啓蟄・末侯"},
                     {"day":21,"ko":"春分・初侯"},{"day":26,"ko":"春分・次侯"},
                     {"day":31,"ko":"春分・末侯"}];
    kotbl["201804"]=[{"day":01,"ko":"春分・末侯"},{"day":05,"ko":"清明・初侯"},
                     {"day":10,"ko":"清明・次侯"},{"day":15,"ko":"清明・末侯"},
                     {"day":20,"ko":"穀雨・初侯"},{"day":25,"ko":"穀雨・次侯"},
                     {"day":30,"ko":"穀雨・末侯"}];
    kotbl["201805"]=[{"day":01,"ko":"穀雨・末侯"},{"day":05,"ko":"立夏・初侯"},
                     {"day":11,"ko":"立夏・次侯"},{"day":16,"ko":"立夏・末侯"},
                     {"day":21,"ko":"小満・初侯"},{"day":26,"ko":"小満・次侯"},
                     {"day":31,"ko":"小満・末侯"}];
    kotbl["201806"]=[{"day":01,"ko":"小満・末侯"},{"day":06,"ko":"芒種・初侯"},
                     {"day":11,"ko":"芒種・次侯"},{"day":16,"ko":"芒種・末侯"},
                     {"day":21,"ko":"夏至・初侯"},{"day":27,"ko":"夏至・次侯"}];
    kotbl["201807"]=[{"day":01,"ko":"夏至・次侯"},{"day":02,"ko":"夏至・末侯"},
                     {"day":07,"ko":"小暑・初侯"},{"day":12,"ko":"小暑・次侯"},
                     {"day":18,"ko":"小暑・末侯"},{"day":23,"ko":"大暑・初侯"},
                     {"day":28,"ko":"大暑・次侯"}];
    kotbl["201808"]=[{"day":01,"ko":"大暑・次侯"},{"day":02,"ko":"大暑・末侯"},
                     {"day":07,"ko":"立秋・初侯"},{"day":13,"ko":"立秋・次侯"},
                     {"day":18,"ko":"立秋・末侯"},{"day":23,"ko":"処暑・初侯"},
                     {"day":28,"ko":"処暑・次侯"}];
    kotbl["201809"]=[{"day":01,"ko":"処暑・次侯"},{"day":02,"ko":"処暑・末侯"},
                     {"day":08,"ko":"白露・初侯"},{"day":13,"ko":"白露・次侯"},
                     {"day":18,"ko":"白露・末侯"},{"day":23,"ko":"秋分・初侯"},
                     {"day":28,"ko":"秋分・次侯"}];
    kotbl["201810"]=[{"day":01,"ko":"秋分・次侯"},{"day":03,"ko":"秋分・末侯"},
                     {"day":08,"ko":"寒露・初侯"},{"day":13,"ko":"寒露・次侯"},
                     {"day":18,"ko":"寒露・末侯"},{"day":23,"ko":"霜降・初侯"},
                     {"day":28,"ko":"霜降・次侯"}];
    kotbl["201811"]=[{"day":01,"ko":"霜降・次侯"},{"day":02,"ko":"霜降・末侯"},
                     {"day":07,"ko":"立冬・初侯"},{"day":12,"ko":"立冬・次侯"},
                     {"day":17,"ko":"立冬・末侯"},{"day":22,"ko":"小雪・初侯"},
                     {"day":27,"ko":"小雪・次侯"}];
    kotbl["201812"]=[{"day":01,"ko":"小雪・次侯"},{"day":02,"ko":"小雪・末侯"},
                     {"day":07,"ko":"大雪・初侯"},{"day":12,"ko":"大雪・次侯"},
                     {"day":17,"ko":"大雪・末侯"},{"day":22,"ko":"冬至・初侯"},
                     {"day":27,"ko":"冬至・次侯"}];
    kotbl["201901"]=[{"day":01,"ko":"冬至・末侯"},{"day":06,"ko":"小寒・初侯"},
                     {"day":10,"ko":"小寒・次侯"},{"day":15,"ko":"小寒・末侯"},
                     {"day":20,"ko":"大寒・初侯"},{"day":25,"ko":"大寒・次侯"},
                     {"day":30,"ko":"大寒・末侯"}];
    kotbl["201902"]=[{"day":01,"ko":"大寒・末侯"},{"day":04,"ko":"立春・初侯"},
                     {"day":09,"ko":"立春・次侯"},{"day":14,"ko":"立春・末侯"},
                     {"day":19,"ko":"雨水・初侯"},{"day":24,"ko":"雨水・次侯"}];
    kotbl["201903"]=[{"day":01,"ko":"雨水・末侯"},{"day":06,"ko":"啓蟄・初侯"},
                     {"day":11,"ko":"啓蟄・次侯"},{"day":16,"ko":"啓蟄・末侯"},
                     {"day":21,"ko":"春分・初侯"},{"day":26,"ko":"春分・次侯"},
                     {"day":31,"ko":"春分・末侯"}];
    kotbl["201904"]=[{"day":01,"ko":"春分・末侯"},{"day":05,"ko":"清明・初侯"},
                     {"day":10,"ko":"清明・次侯"},{"day":15,"ko":"清明・末侯"},
                     {"day":20,"ko":"穀雨・初侯"},{"day":25,"ko":"穀雨・次侯"}];
    kotbl["201905"]=[{"day":01,"ko":"穀雨・末侯"},{"day":06,"ko":"立夏・初侯"},
                     {"day":11,"ko":"立夏・次侯"},{"day":16,"ko":"立夏・末侯"},
                     {"day":21,"ko":"小満・初侯"},{"day":26,"ko":"小満・次侯"}];
    kotbl["201906"]=[{"day":01,"ko":"小満・末侯"},{"day":06,"ko":"芒種・初侯"},
                     {"day":11,"ko":"芒種・次侯"},{"day":16,"ko":"芒種・末侯"},
                     {"day":22,"ko":"夏至・初侯"},{"day":27,"ko":"夏至・次侯"}];
    kotbl["201907"]=[{"day":01,"ko":"夏至・次侯"},{"day":02,"ko":"夏至・末侯"},
                     {"day":07,"ko":"小暑・初侯"},{"day":13,"ko":"小暑・次侯"},
                     {"day":18,"ko":"小暑・末侯"},{"day":23,"ko":"大暑・初侯"},
                     {"day":28,"ko":"大暑・次侯"}];
    kotbl["201908"]=[{"day":01,"ko":"大暑・次侯"},{"day":02,"ko":"大暑・末侯"},
                     {"day":08,"ko":"立秋・初侯"},{"day":13,"ko":"立秋・次侯"},
                     {"day":18,"ko":"立秋・末侯"},{"day":23,"ko":"処暑・初侯"},
                     {"day":28,"ko":"処暑・次侯"}];
    kotbl["201909"]=[{"day":01,"ko":"処暑・次侯"},{"day":03,"ko":"処暑・末侯"},
                     {"day":08,"ko":"白露・初侯"},{"day":13,"ko":"白露・次侯"},
                     {"day":18,"ko":"白露・末侯"},{"day":23,"ko":"秋分・初侯"},
                     {"day":28,"ko":"秋分・次侯"}];
    kotbl["201910"]=[{"day":01,"ko":"秋分・次侯"},{"day":03,"ko":"秋分・末侯"},
                     {"day":08,"ko":"寒露・初侯"},{"day":14,"ko":"寒露・次侯"},
                     {"day":19,"ko":"寒露・末侯"},{"day":24,"ko":"霜降・初侯"},
                     {"day":29,"ko":"霜降・次侯"}];
    kotbl["201911"]=[{"day":01,"ko":"霜降・次侯"},{"day":03,"ko":"霜降・末侯"},
                     {"day":08,"ko":"立冬・初侯"},{"day":13,"ko":"立冬・次侯"},
                     {"day":18,"ko":"立冬・末侯"},{"day":22,"ko":"小雪・初侯"},
                     {"day":27,"ko":"小雪・次侯"}];
    kotbl["201912"]=[{"day":01,"ko":"小雪・次侯"},{"day":02,"ko":"小雪・末侯"},
                     {"day":07,"ko":"大雪・初侯"},{"day":12,"ko":"大雪・次侯"},
                     {"day":17,"ko":"大雪・末侯"},{"day":22,"ko":"冬至・初侯"},
                     {"day":27,"ko":"冬至・次侯"}];
    kotbl["202001"]=[{"day":01,"ko":"冬至・末侯"},{"day":06,"ko":"小寒・初侯"},
                     {"day":11,"ko":"小寒・次侯"},{"day":16,"ko":"小寒・末侯"},
                     {"day":20,"ko":"大寒・初侯"},{"day":25,"ko":"大寒・次侯"},
                     {"day":30,"ko":"大寒・末侯"}];
    kotbl["202002"]=[{"day":01,"ko":"大寒・末侯"},{"day":04,"ko":"立春・初侯"},
                     {"day":09,"ko":"立春・次侯"},{"day":14,"ko":"立春・末侯"},
                     {"day":19,"ko":"雨水・初侯"},{"day":24,"ko":"雨水・次侯"},
                     {"day":29,"ko":"雨水・末侯"}];
    kotbl["202003"]=[{"day":01,"ko":"雨水・末侯"},{"day":05,"ko":"啓蟄・初侯"},
                     {"day":10,"ko":"啓蟄・次侯"},{"day":15,"ko":"啓蟄・末侯"},
                     {"day":20,"ko":"春分・初侯"},{"day":25,"ko":"春分・次侯"},
                     {"day":30,"ko":"春分・末侯"}];
    kotbl["202004"]=[{"day":01,"ko":"春分・末侯"},{"day":04,"ko":"清明・初侯"},
                     {"day":09,"ko":"清明・次侯"},{"day":14,"ko":"清明・末侯"},
                     {"day":19,"ko":"穀雨・初侯"},{"day":25,"ko":"穀雨・次侯"},
                     {"day":30,"ko":"穀雨・末侯"}];
    kotbl["202005"]=[{"day":01,"ko":"穀雨・末侯"},{"day":05,"ko":"立夏・初侯"},
                     {"day":10,"ko":"立夏・次侯"},{"day":15,"ko":"立夏・末侯"},
                     {"day":20,"ko":"小満・初侯"},{"day":26,"ko":"小満・次侯"},
                     {"day":31,"ko":"小満・末侯"}];
    kotbl["202006"]=[{"day":01,"ko":"小満・末侯"},{"day":05,"ko":"芒種・初侯"},
                     {"day":10,"ko":"芒種・次侯"},{"day":16,"ko":"芒種・末侯"},
                     {"day":21,"ko":"夏至・初侯"},{"day":26,"ko":"夏至・次侯"}];
    kotbl["202007"]=[{"day":01,"ko":"夏至・末侯"},{"day":07,"ko":"小暑・初侯"},
                     {"day":12,"ko":"小暑・次侯"},{"day":17,"ko":"小暑・末侯"},
                     {"day":22,"ko":"大暑・初侯"},{"day":27,"ko":"大暑・次侯"}];
    kotbl["202008"]=[{"day":01,"ko":"大暑・次侯"},{"day":02,"ko":"大暑・末侯"},
                     {"day":07,"ko":"立秋・初侯"},{"day":12,"ko":"立秋・次侯"},
                     {"day":17,"ko":"立秋・末侯"},{"day":23,"ko":"処暑・初侯"},
                     {"day":28,"ko":"処暑・次侯"}];
    kotbl["202009"]=[{"day":01,"ko":"処暑・次侯"},{"day":02,"ko":"処暑・末侯"},
                     {"day":07,"ko":"白露・初侯"},{"day":12,"ko":"白露・次侯"},
                     {"day":17,"ko":"白露・末侯"},{"day":22,"ko":"秋分・初侯"},
                     {"day":28,"ko":"秋分・次侯"}];
    kotbl["202010"]=[{"day":01,"ko":"秋分・次侯"},{"day":03,"ko":"秋分・末侯"},
                     {"day":08,"ko":"寒露・初侯"},{"day":13,"ko":"寒露・次侯"},
                     {"day":18,"ko":"寒露・末侯"},{"day":23,"ko":"霜降・初侯"},
                     {"day":28,"ko":"霜降・次侯"}];
    kotbl["202011"]=[{"day":01,"ko":"霜降・次侯"},{"day":02,"ko":"霜降・末侯"},
                     {"day":07,"ko":"立冬・初侯"},{"day":12,"ko":"立冬・次侯"},
                     {"day":17,"ko":"立冬・末侯"},{"day":22,"ko":"小雪・初侯"},
                     {"day":27,"ko":"小雪・次侯"}];
    kotbl["202012"]=[{"day":01,"ko":"小雪・次侯"},{"day":02,"ko":"小雪・末侯"},
                     {"day":07,"ko":"大雪・初侯"},{"day":11,"ko":"大雪・次侯"},
                     {"day":16,"ko":"大雪・末侯"},{"day":21,"ko":"冬至・初侯"},
                     {"day":26,"ko":"冬至・次侯"},{"day":31,"ko":"冬至・末侯"}];
 
    // もし年のテーブルがなければ mod4 の結果で以下のテーブルを参照する
    // 0: 2020; 1: 2017; 2: 2018; 3: 2019;
    if (cyear > 2020) {
        var mod4 = cyear % 4;
        switch (mod4) {
        case 0: cyear = 2020; break;
        case 1: cyear = 2017; break;
        case 2: cyear = 2018; break;
        case 3: cyear = 2019; break;
        }
    }
 
    var ymkey = String(cyear) + ("0" + cmonth).slice(-2); // 年月を文字列化
 
    // 七十二候を特定
    var koname;
    var len = kotbl[ymkey].length;
    for (var i = 0; i < len; i++) {
        if (cday < kotbl[ymkey][i].day) {
            return koname;
        } else {
            koname = kotbl[ymkey][i].ko;
        }
    }
    return koname;
}
 
// 七十二候解説句・読み取得
function getkokaisetsu(koname) {
    var desc = new Array(); // 七十二候とその解説句・読み一覧テーブル
    desc["立春・初侯"] = { "kai": "東風解凍", "yomi": "とうふうこおりをとく" };
    desc["立春・次侯"] = { "kai": "黃鳥睍睆", "yomi": "うぐいすなく" };
    desc["立春・末侯"] = { "kai": "魚上氷", "yomi": "うおこおりにあがる" };
    desc["雨水・初侯"] = { "kai": "土脉潤起", "yomi": "どみゃくうるおいおこる" };
    desc["雨水・次侯"] = { "kai": "霞始靆", "yomi": "かすみはじめてたなびく" };
    desc["雨水・末侯"] = { "kai": "草木萠動", "yomi": "そうもくもえうごく" };
    desc["啓蟄・初侯"] = { "kai": "蟄蟲啓戸", "yomi": "すごもりむしとをひらく" };
    desc["啓蟄・次侯"] = { "kai": "桃始笑", "yomi": "ももはじめてさく" };
    desc["啓蟄・末侯"] = { "kai": "菜蟲爲蝶", "yomi": "なむしちょうとなる" };
    desc["春分・初侯"] = { "kai": "雀始巢", "yomi": "すずめはじめてすくう" };
    desc["春分・次侯"] = { "kai": "櫻始開", "yomi": "さくらはじめてひらく" };
    desc["春分・末侯"] = { "kai": "雷乃發聲", "yomi": "かみなりすなわちこえをはっす" };
    desc["清明・初侯"] = { "kai": "玄鳥至", "yomi": "つばめいたる" };
    desc["清明・次侯"] = { "kai": "鴻雁北", "yomi": "かりきたにゆく" };
    desc["清明・末侯"] = { "kai": "虹始見", "yomi": "にじはじめてあらわる" };
    desc["穀雨・初侯"] = { "kai": "葭始生", "yomi": "あしはじめてしょうず" };
    desc["穀雨・次侯"] = { "kai": "霜止苗出", "yomi": "しもやみなえでる" };
    desc["穀雨・末侯"] = { "kai": "牡丹華", "yomi": "ぼたんはなさく" };
    desc["立夏・初侯"] = { "kai": "元黽始鳴", "yomi": "がまはじめてなく" };
    desc["立夏・次侯"] = { "kai": "蚯蚓出", "yomi": "みみずいずる" };
    desc["立夏・末侯"] = { "kai": "竹箒生", "yomi": "たけのこしょうず" };
    desc["小満・初侯"] = { "kai": "蠶起食桑", "yomi": "かいこおきてくわをくう" };
    desc["小満・次侯"] = { "kai": "紅花榮", "yomi": "べにばなさかう" };
    desc["小満・末侯"] = { "kai": "麥秋至", "yomi": "むぎのほでる" };
    desc["芒種・初侯"] = { "kai": "蟷螂生", "yomi": "かまきりしょうず" };
    desc["芒種・次侯"] = { "kai": "腐草爲螢", "yomi": "ふそうほたるとなる" };
    desc["芒種・末侯"] = { "kai": "梅子黃", "yomi": "うめのみきばむ" };
    desc["夏至・初侯"] = { "kai": "乃東枯", "yomi": "かこそう(なつかれくさ)かるる" };
    desc["夏至・次侯"] = { "kai": "菖蒲華", "yomi": "あやめはなさく" };
    desc["夏至・末侯"] = { "kai": "半夏生", "yomi": "はんげしょうず" };
    desc["小暑・初侯"] = { "kai": "溫風至", "yomi": "おんぷういたる" };
    desc["小暑・次侯"] = { "kai": "蓮始開", "yomi": "はすはじめてひらく" };
    desc["小暑・末侯"] = { "kai": "鷹之學習", "yomi": "たかすなわちわざをならう" };
    desc["大暑・初侯"] = { "kai": "桐始結華", "yomi": "きりはじめてはなをむすぶ" };
    desc["大暑・次侯"] = { "kai": "土潤溽暑", "yomi": "つちうるおいてむしあつし" };
    desc["大暑・末侯"] = { "kai": "大雨時行", "yomi": "だいうときどきふる" };
    desc["立秋・初侯"] = { "kai": "涼風至", "yomi": "りょうふういたる" };
    desc["立秋・次侯"] = { "kai": "寒蟬鳴", "yomi": "ひぐらしなく" };
    desc["立秋・末侯"] = { "kai": "蒙霧升降", "yomi": "さかんにきり(のうむ)しょうこうす" };
    desc["処暑・初侯"] = { "kai": "綿析開", "yomi": "わたのはなしべひらく" };
    desc["処暑・次侯"] = { "kai": "天地始肅", "yomi": "てんちはじめてさむし" };
    desc["処暑・末侯"] = { "kai": "禾乃登", "yomi": "こくものみのる" };
    desc["白露・初侯"] = { "kai": "草露白", "yomi": "くさのつゆしろし" };
    desc["白露・次侯"] = { "kai": "鶺鴒鳴", "yomi": "せきれいなく" };
    desc["白露・末侯"] = { "kai": "玄鳥去", "yomi": "つばめさる" };
    desc["秋分・初侯"] = { "kai": "雷乃收聲", "yomi": "かみなりすなわちこえをおさむ" };
    desc["秋分・次侯"] = { "kai": "蟄蟲坏戸", "yomi": "すごもりのむしとをとざす" };
    desc["秋分・末侯"] = { "kai": "水始涸", "yomi": "みずはじめてかるる" };
    desc["寒露・初侯"] = { "kai": "鴻雁來", "yomi": "がんきたる" };
    desc["寒露・次侯"] = { "kai": "菊花開", "yomi": "きっかひらく" };
    desc["寒露・末侯"] = { "kai": "蟋蟀在戸", "yomi": "こおろぎとにあり" };
    desc["霜降・初侯"] = { "kai": "霜始降", "yomi": "しもはじめてふる" };
    desc["霜降・次侯"] = { "kai": "霎時施", "yomi": "こさめときどきほどこす" };
    desc["霜降・末侯"] = { "kai": "楓蔦黃", "yomi": "もみじつたきなり" };
    desc["立冬・初侯"] = { "kai": "山茶花始開", "yomi": "さざんかはじめてひらく" };
    desc["立冬・次侯"] = { "kai": "地始凍", "yomi": "ちはじめてこおる" };
    desc["立冬・末侯"] = { "kai": "金盞香", "yomi": "きんせんかおる" };
    desc["小雪・初侯"] = { "kai": "虹藏不見", "yomi": "にじかくれてみえず" };
    desc["小雪・次侯"] = { "kai": "朔風拂葉", "yomi": "きたかぜはをはらう" };
    desc["小雪・末侯"] = { "kai": "橘始黃", "yomi": "みかんはじめてきばむ" };
    desc["大雪・初侯"] = { "kai": "閉塞成冬", "yomi": "そらさむくふゆとなる" };
    desc["大雪・次侯"] = { "kai": "熊蟄穴", "yomi": "くまあなにこもる" };
    desc["大雪・末侯"] = { "kai": "鱖魚群", "yomi": "さけむらがる" };
    desc["冬至・初侯"] = { "kai": "乃東生", "yomi": "かこそう(なつかれくさ)しょうず" };
    desc["冬至・次侯"] = { "kai": "糜角解", "yomi": "さわしかのつのおつる" };
    desc["冬至・末侯"] = { "kai": "雪下麥出", "yomi": "ゆきのしたむぎいづ(せっかむぎをいだす)" };
    desc["小寒・初侯"] = { "kai": "芹乃榮", "yomi": "せりすなわちさかう" };
    desc["小寒・次侯"] = { "kai": "水泉動", "yomi": "すいせんうごく" };
    desc["小寒・末侯"] = { "kai": "雉始鳴", "yomi": "きじはじめてなく" };
    desc["大寒・初侯"] = { "kai": "疑冬華", "yomi": "ふきのはなさく" };
    desc["大寒・次侯"] = { "kai": "水澤腹堅", "yomi": "すいたくあつくかたし" };
    desc["大寒・末侯"] = { "kai": "鷄始乳", "yomi": "にわとりはじめてにゅうす" };
 
    if (desc[koname] != undefined) {
        return desc[koname];
    } else {
        // エラーデータ: キーが存在しない場合
        return { "kai": "未定義キー: " + koname,
                 "yomi": "key: " + koname + " is not available." };
    }
}
[ 2015/4/21 付記 ] 七十二候解説テーブルにバグがあったので訂正した。キーが旧字体だったため koname に入って来る「穀雨」,「小満」がキーの「」,「滿」(ともに旧字体)とマッチせず解説文・読みを引けなかった。新字体にすることで訂正するとともに,未定義エラーを検知できるようにした。
 

角川の歳時記は,私の手元にある第三版ではなくて,最新の第四版をあげておきます。