高精度旧暦ライブラリ — 干支 · 生肖 · 節気 · 祝日 · フォーマット · 多言語
天文アルゴリズムに基づく旧暦計算。中国・日本・韓国・ベトナムの4種類の旧暦バリアント、および簡体字中国語・繁體字中國語(台灣/香港)・日本語・한국어・Tiếng Việt の6言語に対応。
Copyright (c) 2025 北京锋通科技有限公司 (郭玉峰, 吴琼). MIT License.
import { ChineseDate } from 'chinese-lunar-date'
const date = ChineseDate.fromGregorian(2024, 6, 21)
date.yearGanZhi // "甲辰"
date.zodiac // "辰"
date.zodiacEmoji // "🐉"
date.formatFull() // "甲辰辰年 五月初六"
CalendarConfig で設定駆動。異なる紀元とタイムゾーン履歴に同じアルゴリズムで対応ChineseDate 等)は不変値オブジェクト、低レベルアルゴリズムはすべて純関数。2つのモードを独立して使用可能| chinese-lunar-date | date-chinese | lunar-javascript | |
|---|---|---|---|
| 精度 | 天文アルゴリズム(VSOP87) | 天文アルゴリズム | 查表法 |
| TypeScript | ネイティブ TS、完全型定義 | JSDoc アノテーション | コミュニティ @types |
| API スタイル | 不変値オブジェクト | 関数型 + 内部クラス | ミュータブルオブジェクト |
| 干支 | 年月日三柱 | 年柱のみ | 年月日三柱 |
| 生肖 | 6言語 + Emoji | なし | 中国語のみ |
| 節気 | 24節気、6言語 | なし | 中国語のみ |
| 祝日 | 13種、地域別フィルタ | なし | 中国語のみ |
| 多暦法 | 中 / 日 / 韓 / 越 | 中国のみ | 中国のみ |
| 繁體字 | zh-TW / zh-HK 個別対応 | なし | なし |
| フォーマット | 5種内蔵 + カスタムパターン | なし | 限定 |
| サイズ (gzip) | ~16 KB | ~15 KB | ~20 KB |
with() / addDays() は新インスタンスを返すzh-CN / zh-TW / zh-HK / ja-JP / ko-KR / vi-VNnpm install chinese-lunar-date
import { ChineseDate } from 'chinese-lunar-date'
const date = ChineseDate.fromGregorian(2024, 6, 21)
const date2 = ChineseDate.fromDate(new Date(2024, 5, 21))
const today = ChineseDate.today()
const date3 = ChineseDate.fromValue({ cycle: 78, year: 34, month: 5, leap: false, day: 6 })
const date = ChineseDate.fromGregorian(2024, 6, 21)
date.cycle // 78
date.year // 34
date.month // 5
date.leap // false
date.day // 6
date.gregorianYear // 2024
date.yearGanZhi // "甲辰"
date.monthGanZhi // "庚午"
date.dayGanZhi // "甲寅"
date.zodiac // "辰"
date.zodiacEmoji // "🐉"
date.zodiacIndex // 4
const date = ChineseDate.fromGregorian(2024, 6, 21)
date.formatFull('ja-JP') // "甲辰辰年 五月初六"
date.formatGanZhi() // "甲辰年 庚午月 甲寅日"
date.formatCompact() // "78/34/5/0/6"
date.format('{Ygz}{Z}年 {Mname}{Dname}', 'ja-JP') // "甲辰辰年 五月初六"
const date = ChineseDate.fromGregorian(2024, 6, 21)
const tomorrow = date.addDays(1)
const yesterday = date.addDays(-1)
const firstDay = date.with({ day: 1 })
tomorrow.isAfter(date) // true
const date = ChineseDate.fromGregorian(2024, 6, 21)
date.toGregorian() // { year: 2024, month: 6, day: 21 }
date.toDate() // Date object
date.toJSON() // { cycle: 78, year: 34, month: 5, leap: false, day: 6 }
import { ChineseDate, JapaneseDate, KoreanDate, VietnameseDate } from 'chinese-lunar-date'
const cn = ChineseDate.fromGregorian(2024, 6, 21) // UTC+8
const jp = JapaneseDate.fromGregorian(2024, 6, 21) // UTC+9
const kr = KoreanDate.fromGregorian(2024, 6, 21) // UTC+8:30/9
const vn = VietnameseDate.fromGregorian(2024, 6, 21) // UTC+7/8
注意:タイムゾーンの違いにより、同じ西暦日付でも異なる暦では異なる旧暦日付に対応する場合があります。
import { ChineseDate, solarTermName } from 'chinese-lunar-date'
ChineseDate.solarTerm(5, 2024) // 清明
solarTermName(3, 'ja-JP') // "啓蟄"
const date = ChineseDate.fromGregorian(2024, 4, 4)
date.getSolarTermName('ja-JP') // "清明"
import { ChineseDate } from 'chinese-lunar-date'
ChineseDate.festivalDate('spring', 2024)
ChineseDate.festivalsInYear(2024, 'ja-JP')
import { getLocale, availableLocales } from 'chinese-lunar-date'
const loc = getLocale('ja-JP')
loc.gan // ["甲", "乙", "丙", ...]
loc.zhi // ["子", "丑", "寅", ...]
loc.zodiac // ["鼠", "牛", "虎", "兔", "竜", "蛇", "馬", "羊", "猿", "鶏", "犬", "猪"]
loc.monthNames(12, false) // "師走"
loc.solarTerms // ["立春", "雨水", "啓蟄", ...]
| Token | 出力 | 例 |
|---|---|---|
{Ygz} |
年干支 | 甲辰 |
{Z} |
生肖 | 辰 |
{Mname} |
月名 | 五月 |
{Dname} |
日名 | 初六 |
{L} |
閏月マーク | 閏 |
{GY} |
西暦年 | 2024 |
{Wname} |
曜日 | 金曜日 |
完全な Token リストは使用手引きを参照してください。
<script src="dist/chinese-lunar-date.iife.js"></script>
<script>
const date = ChineseDate.ChineseDate.fromGregorian(2024, 6, 21)
console.log(date.formatFull('ja-JP')) // "甲辰辰年 五月初六"
</script>
npm install chinese-lunar-date
npm run build # ESM + CJS + IIFE をコンパイル
npm run build:types # .d.ts 型宣言を生成
npm run test # テストを実行
ご利用中の問題、機能リクエスト、ビジネス協力などがございましたら、メールにてお気軽にお問い合わせください:
MIT License
Copyright (c) 2025 北京锋通科技有限公司 (郭玉峰, 吴琼)