日本の和暦西暦変換データおよび Web コンバーター
Harumi (春海): Japanese-Western calendar open data and web converter.
Project name is named from 渋川春海(Harumi Shibukawa), who was known as Japanese Astronomer in 17th-18th century.
npm install harumi
import { ambiguousSearch } from 'harumi';
// 基本的な検索
const results = ambiguousSearch('寛永');
console.log(results);
// [
// { year: 1624, nengo: '寛永1', eto: '甲子' },
// { year: 1625, nengo: '寛永2', eto: '乙丑' },
// ...
// ]
// オプション付きの検索
const options = {
range: '1600-1700', // 西暦年の範囲指定
enable_over_match: true, // 延長マッチを有効化
tsuchinoe_inu_flag: true, // 「戊」と「戌」を同一視
tsuchinoto_mi_flag: true // 「己」と「巳」を同一視
};
const results2 = ambiguousSearch('寛永', options);
-
range
: 検索対象とする西暦年の範囲を指定(例: '1600-1700') -
enable_over_match
: 元号の延長期間も検索対象に含める(デフォルト: false) -
tsuchinoe_inu_flag
: 「戊」と「戌」を同一の文字として扱う(デフォルト: false) -
tsuchinoto_mi_flag
: 「己」と「巳」を同一の文字として扱う(デフォルト: false)
interface SearchResult {
year: number; // 西暦年
nengo: string; // 年号
eto?: string; // 干支
condition?: string; // 条件(例: "南朝")
over_match?: boolean; // 延長マッチかどうか
}
石碑の年号が部分的にしか判読できない場合の年代推定:
// 「慶」の文字だけが判読できる場合
const results = ambiguousSearch('慶');
// 「応」の文字と1860年代という情報がある場合
const results = ambiguousSearch('応', { range: '1860-1869' });
// 「戊」か「戌」かはっきりしない場合
const results = ambiguousSearch('戊', { tsuchinoe_inu_flag: true });
MIT License
Copyright (c) 2024 Code for History
あなたの貢献をお待ちしています!イシューやプルリクエストは大歓迎です。