Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

manseryeok

ํ•œ๊ตญ ์‚ฌ์ฃผยท๋งŒ์„ธ๋ ฅ ๊ณ„์‚ฐ์„ ์œ„ํ•œ TypeScript ์—”์ง„์ž…๋‹ˆ๋‹ค. ์ƒ๋…„์›”์ผ์‹œ ์ž…๋ ฅ์„ ์Œ์–‘๋ ฅ, ์œค๋‹ฌ, ํ•œ๊ตญ ๋ฒ•์ •์‹œ, ์ ˆ๊ธฐ ๊ฒฝ๊ณ„, ์ž์‹œ ๊ธฐ์ค€, ์ง„ํƒœ์–‘์‹œ ๋ณด์ • ์ •์ฑ…์— ๋”ฐ๋ผ ์ •๊ทœํ™”ํ•˜๊ณ  ์‚ฌ์ฃผํŒ”์ž์™€ ๊ด€๋ จ ์šด์„ธ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

ํฌํ•จ ๊ธฐ๋Šฅ

๋งŒ์„ธ๋ ฅ ํ•ต์‹ฌ

  • ์–‘๋ ฅ ์ž…๋ ฅ๊ณผ ์Œ๋ ฅ ์ž…๋ ฅ ์ง€์›
  • ์Œ๋ ฅ ์œค๋‹ฌ ๋ณ€ํ™˜ ์ง€์›
  • ํ•œ๊ตญ ๋ฒ•์ •์‹œ ์ •์ฑ… ๋ฐ˜์˜
    • UTC+08:30 ์‹œ๊ธฐ
    • UTC+09:00 ์‹œ๊ธฐ
    • 19481960, 19871988 ํ•˜์ ˆ๊ธฐ/DST
    • ์กด์žฌํ•˜์ง€ ์•Š๋Š” ๋ฏผ๊ฐ„์‹œ๊ฐ๊ณผ ์ค‘๋ณต ๋ฏผ๊ฐ„์‹œ๊ฐ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ
  • ์ง„ํƒœ์–‘์‹œ ๋ณด์ •
    • ๊ด€์ธก์ง€ ๊ฒฝ๋„
    • ๊ธฐ์ค€ ์ž์˜ค์„ 
    • ๊ท ์‹œ์ฐจ
  • 24์ ˆ๊ธฐ ๋ฐ์ดํ„ฐ์™€ ์ ˆ์ž… ์‹œ๊ฐ ๊ธฐ๋ฐ˜ ์›”์ฃผ ๊ณ„์‚ฐ
  • ์—ฐ์ฃผ, ์›”์ฃผ, ์ผ์ฃผ, ์‹œ์ฃผ ๊ณ„์‚ฐ
  • ์•ผ์ž์‹œ/์กฐ์ž์‹œ ๊ธฐ์ค€ ์„ ํƒ
  • ์ง€์› ๋ฒ”์œ„: ๊ณต๊ฐœ ๊ณ„์‚ฐ ๊ธฐ์ค€ 1908-04-01 ~ 2101๋…„, ๋‚ด๋ถ€ ์ ˆ๊ธฐ/์Œ์–‘๋ ฅ ์›์ฒœ ๋ฐ์ดํ„ฐ 1899 ~ 2101๋…„

์‚ฌ์ฃผ ๋ถ„์„

  • ํŒ”์ž ์‚ฐ์ถœ
  • ๋Œ€์šด, ์„ธ์šด, ์›”์šด ๊ณ„์‚ฐ
  • ๋Œ€์šด ์‹œ์ž‘ ๋‚˜์ด์™€ ์‹œ์ž‘ ๊ฐœ์›” ์ˆ˜ ๊ณ„์‚ฐ
  • ์‹ญ์‹  ๊ณ„์‚ฐ
  • ์ง€์žฅ๊ฐ„ ์‹ญ์‹  ๊ณ„์‚ฐ
  • ์šด์„ฑ ๊ณ„์‚ฐ
  • ์‹ ์‚ด ๊ณ„์‚ฐ
  • ์ง€์ง€ ํ•ฉยท์ถฉยทํ˜•ยทํŒŒยทํ•ด ๊ด€๊ณ„ ๋ถ„์„
  • ๊ณต๋ง ๊ณ„์‚ฐ
  • ๋‚ฉ์Œ์˜คํ–‰ ๊ณ„์‚ฐ
  • ์›์ง„ ๋ถ„์„
  • ๊ฒฉ๊ตญ ํŒ๋‹จ
  • ์šฉ์‹  ํŒ๋‹จ

ํ™•์žฅ ์—”์ง„

  • ๊ถํ•ฉ
  • ๋‹ฌ๋ ฅ
  • ์ž‘๋ช…
  • ์ž๋ฏธ๋‘์ˆ˜
  • ๊ธฐ๋ฌธ๋‘”๊ฐ‘
  • ํ† ์ •๋น„๊ฒฐ
  • ๋Œ€์œก์ž„
  • ํ™์—ฐ
  • ๋งคํ™”์—ญ์ˆ˜
  • ํ•˜๋ฝ์ด์ˆ˜
  • ๊ตฌ์„ฑํ•™
  • ๋Œ€์ •์ˆ˜

์„ค์น˜

npm install

๊ฒ€์ฆ

npm run type-check
npm run build
npm test
npm run solar-terms:verify

๊ธฐ๋ณธ ์ž…๋ ฅ ํ˜•์‹

type BirthInputData = {
  year: number;
  month: number;
  day: number;
  hour: number | null;
  minute: number | null;
  gender: 'male' | 'female';
  isLunar: boolean;
  isLeapMonth?: boolean;
  birthPlace: string | null;
};

type CalculateOptions = {
  trueSolarTime?: boolean;
  longitude?: number;
  midnightMode?: 'yaja' | 'joja';
};

์‚ฌ์ฃผํŒ”์ž ๊ณ„์‚ฐ

import { calculatePalja } from 'manseryeok-engine';

const birth = {
  year: 1990,
  month: 3,
  day: 15,
  hour: 14,
  minute: 30,
  gender: 'male' as const,
  isLunar: false,
  birthPlace: 'Seoul',
};

const palja = calculatePalja(birth, {
  trueSolarTime: true,
  longitude: 126.978,
  midnightMode: 'yaja',
});

console.log(palja);
// {
//   yearGan: 'ๅบš',
//   yearJi: 'ๅˆ',
//   monthGan: 'ๅทฑ',
//   monthJi: 'ๅฏ',
//   dayGan: '...',
//   dayJi: '...',
//   hourGan: '...',
//   hourJi: '...'
// }

์ข…ํ•ฉ ์‚ฌ์ฃผ ๊ฒฐ๊ณผ ๊ณ„์‚ฐ

import { buildSajuResult } from 'manseryeok-engine';

const result = buildSajuResult(birth, {
  calculateOptions: {
    trueSolarTime: true,
    longitude: 126.978,
    midnightMode: 'yaja',
  },
  now: new Date('2026-07-07T00:00:00+09:00'),
  subSchool: 'gyeokguk',
});

console.log(result.palja);
console.log(result.sipsin);
console.log(result.daeun);
console.log(result.seun);
console.log(result.wolun);
console.log(result.gyeokguk);
console.log(result.yongsin);

๋Œ€์šดยท์„ธ์šดยท์›”์šด ๊ณ„์‚ฐ

import {
  calculatePalja,
  calculateDaeun,
  calculateSeun,
  calculateWolun,
  calculateYunStartAge,
} from 'manseryeok-engine';

const palja = calculatePalja(birth);
const daeun = calculateDaeun(palja, birth, 8);
const yunStartAge = calculateYunStartAge(birth);
const seun = calculateSeun(2026);
const wolun = calculateWolun(new Date('2026-07-07T00:00:00+09:00'));

console.log({ daeun, yunStartAge, seun, wolun });

์Œ์–‘๋ ฅ ๋ณ€ํ™˜๊ณผ ์ ˆ๊ธฐ ์กฐํšŒ

import { ManseryeokEngine } from 'manseryeok-engine';

const lunar = ManseryeokEngine.solarToLunar({
  year: 1990,
  month: 3,
  day: 15,
  hour: 14,
  minute: 30,
});

const solar = ManseryeokEngine.lunarToSolar({
  year: 1990,
  month: 2,
  day: 19,
  isLeapMonth: false,
  hour: 14,
  minute: 30,
});

const terms = ManseryeokEngine.listSolarTermsForYear(2026);
const context = ManseryeokEngine.getSolarContext({
  year: 2026,
  month: 2,
  day: 4,
  hour: 5,
  minute: 0,
});

console.log({ lunar, solar, terms, context });

์ •๊ทœํ™” ์ปจํ…์ŠคํŠธ ํ™•์ธ

import { createNormalizedManseryeokContext } from 'manseryeok-engine';

const context = createNormalizedManseryeokContext(birth, {
  trueSolarTime: true,
  longitude: 126.978,
  midnightMode: 'yaja',
});

console.log(context.legalTime);
console.log(context.trueSolar);
console.log(context.yearMonthContextDateTime);
console.log(context.dayHourContextDateTime);

์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ

ํ•œ๊ตญ ๋ฒ•์ •์‹œ ์ „ํ™˜ ๊ตฌ๊ฐ„์—์„œ๋Š” ์ž…๋ ฅ ์‹œ๊ฐ์ด ์กด์žฌํ•˜์ง€ ์•Š๊ฑฐ๋‚˜ ์ค‘๋ณต๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ ๋ช…์‹œ์ ์ธ ์—”์ง„ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

import {
  createNormalizedManseryeokContext,
  ManseryeokPolicyError,
  NonexistentCivilTimeError,
  AmbiguousCivilTimeError,
} from 'manseryeok-engine';

try {
  createNormalizedManseryeokContext({
    year: 1961,
    month: 8,
    day: 10,
    hour: 0,
    minute: 15,
    gender: 'male',
    isLunar: false,
    birthPlace: null,
  });
} catch (error) {
  if (error instanceof NonexistentCivilTimeError) {
    console.error('์กด์žฌํ•˜์ง€ ์•Š๋Š” ๋ฏผ๊ฐ„์‹œ๊ฐ์ž…๋‹ˆ๋‹ค.', error.context);
  } else if (error instanceof AmbiguousCivilTimeError) {
    console.error('์ค‘๋ณต ๋ฏผ๊ฐ„์‹œ๊ฐ์ž…๋‹ˆ๋‹ค.', error.context);
  } else if (error instanceof ManseryeokPolicyError) {
    console.error('๋งŒ์„ธ๋ ฅ ์ •์ฑ… ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค.', error.context);
  } else {
    throw error;
  }
}

์ฃผ์š” ๊ณต๊ฐœ API

  • calculatePalja(input, options?)
  • buildSajuResult(input, options?)
  • calculateDaeun(palja, input, count?, options?)
  • calculateYunStartAge(input, options?)
  • calculateSeun(yearOrDate)
  • calculateWolun(date)
  • createNormalizedManseryeokContext(input, options?)
  • ManseryeokEngine.solarToLunar(input)
  • ManseryeokEngine.lunarToSolar(input)
  • ManseryeokEngine.getGanji(input)
  • ManseryeokEngine.getSolarContext(input)
  • ManseryeokEngine.listSolarTermsForYear(year)

๋ผ์ด์„ ์Šค

ISC

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages