chinese-lunar-date

๊ณ ์ •๋ฐ€ ์Œ๋ ฅ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ โ€” ๊ฐ„์ง€ ยท ๋  ยท ์ ˆ๊ธฐ ยท ๋ช…์ ˆ ยท ํฌ๋งท ยท ๋‹ค๊ตญ์–ด

์ฒœ๋ฌธ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ธฐ๋ฐ˜ ์Œ๋ ฅ ๊ณ„์‚ฐ. ์ค‘๊ตญยท์ผ๋ณธยทํ•œ๊ตญยท๋ฒ ํŠธ๋‚จ 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()  // "๊ฐ‘์ง„์šฉ๋…„ 5์›”์ดˆ์œก"

๋ณธ ํ”„๋กœ์ ํŠธ์˜ ๋…์ฐฝ์„ฑ

์™œ chinese-lunar-date๋ฅผ ์„ ํƒํ•˜๋Š”๊ฐ€?

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

ํŠน์ง•

์„ค์น˜

npm 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('ko-KR')   // "๊ฐ‘์ง„์šฉ๋…„ 5์›”์ดˆ์œก"
date.formatGanZhi()        // "็”ฒ่พฐๅนด ๅบšๅˆๆœˆ ็”ฒๅฏ…ๆ—ฅ"
date.formatCompact()       // "78/34/5/0/6"
date.format('{Ygz}{Z}๋…„ {Mname}{Dname}', 'ko-KR')  // "๊ฐ‘์ง„์šฉ๋…„ 5์›”์ดˆ์œก"

๋‚ ์งœ ์—ฐ์‚ฐ

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

์ฐธ๊ณ : ์‹œ๊ฐ„๋Œ€ ์ฐจ์ด๋กœ ์ธํ•ด ๊ฐ™์€ ์–‘๋ ฅ ๋‚ ์งœ๊ฐ€ ๋‹ค๋ฅธ ์—ญ๋ฒ•์—์„œ ๋‹ค๋ฅธ ์Œ๋ ฅ ๋‚ ์งœ์— ํ•ด๋‹นํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

24์ ˆ๊ธฐ

import { ChineseDate, solarTermName } from 'chinese-lunar-date'

ChineseDate.solarTerm(5, 2024)   // ์ฒญ๋ช…
solarTermName(3, 'ko-KR')       // "๊ฒฝ์นฉ"

const date = ChineseDate.fromGregorian(2024, 4, 4)
date.getSolarTermName('ko-KR')  // "์ฒญ๋ช…"

์ „ํ†ต ๋ช…์ ˆ

import { ChineseDate } from 'chinese-lunar-date'

ChineseDate.festivalDate('spring', 2024)      // ์ถ˜์ ˆ
ChineseDate.festivalsInYear(2024, 'ko-KR')

๋‹ค๊ตญ์–ด / ๋‹ค์ง€์—ญ

import { getLocale, availableLocales } from 'chinese-lunar-date'

const loc = getLocale('ko-KR')
loc.zodiac        // ["์ฅ", "์†Œ", "ํ˜ธ๋ž‘์ด", "ํ† ๋ผ", "์šฉ", "๋ฑ€", "๋ง", "์–‘", "์›์ˆญ์ด", "๋‹ญ", "๊ฐœ", "๋ผ์ง€"]
loc.solarTerms    // ["์ž…์ถ˜", "์šฐ์ˆ˜", "๊ฒฝ์นฉ", ...]

ํฌ๋งท Token

Token ์ถœ๋ ฅ ์˜ˆ
{Ygz} ์—ฐ๊ฐ„์ง€ ็”ฒ่พฐ
{Z} ๋  ์šฉ
{Mname} ์›”๋ช… 5์›”
{Dname} ์ผ๋ช… ์ดˆ์œก
{L} ์œค๋‹ฌ ํ‘œ์‹œ ์œค
{GY} ์–‘๋ ฅ ์—ฐ 2024
{Wname} ์š”์ผ ์ˆ˜์š”์ผ

์ „์ฒด Token ๋ชฉ๋ก์€์‚ฌ์šฉ ์•ˆ๋‚ด์„œ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

๋ธŒ๋ผ์šฐ์ € ์‚ฌ์šฉ (IIFE)

<script src="dist/chinese-lunar-date.iife.js"></script>
<script>
  const date = ChineseDate.ChineseDate.fromGregorian(2024, 6, 21)
  console.log(date.formatFull('ko-KR'))  // "๊ฐ‘์ง„์šฉ๋…„ 5์›”์ดˆ์œก"
</script>

๋นŒ๋“œ

npm install chinese-lunar-date
npm run build        # ESM + CJS + IIFE ์ปดํŒŒ์ผ
npm run build:types  # .d.ts ํƒ€์ž… ์„ ์–ธ ์ƒ์„ฑ
npm run test         # ํ…Œ์ŠคํŠธ ์‹คํ–‰

ํ”ผ๋“œ๋ฐฑ ๋ฐ ํ˜‘๋ ฅ

์‚ฌ์šฉ ์ค‘ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๊ฑฐ๋‚˜ ๊ธฐ๋Šฅ ์ œ์•ˆ, ๋น„์ฆˆ๋‹ˆ์Šค ํ˜‘๋ ฅ ๋“ฑ์ด ํ•„์š”ํ•˜์‹  ๊ฒฝ์šฐ ์ด๋ฉ”์ผ๋กœ ์—ฐ๋ฝํ•ด ์ฃผ์„ธ์š”๏ผš

๐Ÿ“ง gyfinjava@163.com

License

MIT License

Copyright (c) 2025 ๅŒ—ไบฌ้”‹้€š็ง‘ๆŠ€ๆœ‰้™ๅ…ฌๅธ (้ƒญ็މๅณฐ, ๅด็ผ)