feat: 카카오 앱 키 설정, 절기 기준 계산, 대운 정밀화

카카오 앱 키 설정:
- 환경 변수(.env.local)를 통한 안전한 키 관리
- NEXT_PUBLIC_KAKAO_APP_KEY 환경 변수 사용
- layout.tsx에서 환경 변수 읽어서 Kakao SDK 초기화
- .env.local 템플릿 파일 생성 (키 발급 가이드 포함)

음력 변환 정확도 개선:
- 24절기 계산 라이브러리 구현 (solar-terms.ts)
- 절기 기준 월주 계산으로 정확도 향상
- 입춘, 경칩, 청명 등 12개 월 절기 지원
- getSolarTermMonthBranch() - 절기 기준 월 지지 계산
- getCurrentSolarTerm() - 현재 절기 확인
- 사주 결과 페이지에 절기 정보 표시

대운 시작 나이 정밀 계산:
- 절기 기준 대운수 계산 구현
- 양남음녀(순행), 음남양녀(역행) 정확한 일수 계산
- 3일 = 1세 공식 적용
- calculateDaeunStartAge() 함수로 정밀 계산
- 이전 평균 8세 → 실제 계산값 (1~10세 범위)
- 대운 섹션에 시작 나이 계산 근거 표시

문서화:
- SETUP.md 생성
  - 카카오 앱 키 발급 및 설정 가이드
  - 절기 기준 사주 계산 설명
  - 대운 계산 원리 설명
  - 음력 변환 사용법
  - 기술 스택 및 개발 환경

사주 결과 페이지 개선:
- 절기 정보 표시 (녹색 박스)
- 대운 시작 나이 설명 추가
- 사용자에게 계산 원리 투명하게 공개

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-12 00:07:59 +09:00
parent affbdf1a44
commit e233e18a55
6 changed files with 472 additions and 25 deletions

View File

@@ -13,6 +13,60 @@ export interface DaeunPillar {
branchKr: string; // 지지 한글
}
/**
* 대운 시작 나이 정밀 계산
* @param birthYear 생년
* @param birthMonth 생월
* @param birthDay 생일
* @param gender 성별
* @param isYangYear 양년 여부
* @returns 대운 시작 나이
*/
function calculateDaeunStartAge(
birthYear: number,
birthMonth: number,
birthDay: number,
gender: 'male' | 'female',
isYangYear: boolean
): number {
const { getDaysToNextSolarTerm, getCurrentSolarTerm, getSolarTermDate } = require('./solar-terms');
// 양남음녀는 순행 (다음 절기까지), 음남양녀는 역행 (이전 절기부터)
let days: number;
if ((gender === 'male' && isYangYear) || (gender === 'female' && !isYangYear)) {
// 순행: 생일부터 다음 절기까지의 일수
days = getDaysToNextSolarTerm(birthYear, birthMonth, birthDay);
} else {
// 역행: 이전 절기부터 생일까지의 일수
const currentTerm = getCurrentSolarTerm(birthYear, birthMonth, birthDay);
const termDate = getSolarTermDate(birthYear, currentTerm);
let termYear = termDate.year;
let termMonth = termDate.month;
// 대한, 소한 처리
if (currentTerm >= 22 && birthMonth >= 2) {
termYear = birthYear;
} else if (currentTerm >= 22) {
termYear = birthYear - 1;
}
const termDateObj = new Date(termYear, termMonth - 1, termDate.day);
const birthDateObj = new Date(birthYear, birthMonth - 1, birthDay);
const diffTime = birthDateObj.getTime() - termDateObj.getTime();
days = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
}
// 3일 = 1세 (대운수)
// 정확히는 3일당 1세이지만, 일수를 3으로 나눈 몫
const startAge = Math.floor(days / 3);
// 최소 1세, 최대 10세로 제한
return Math.max(1, Math.min(10, startAge));
}
/**
* 대운 계산
* @param birthYear 생년
@@ -49,9 +103,8 @@ export function calculateDaeun(
isForward = !isYangYear; // 양녀: 역행, 음녀: 순행
}
// 대운 시작 나이 계산 (간단화: 평균 8세로 설정)
// 실제로는 절입일부터 생일까지의 일수를 계산해야 하지만 복잡하므로 단순화
const startAge = 8;
// 대운 시작 나이 정밀 계산 (절기 기준)
const startAge = calculateDaeunStartAge(birthYear, birthMonth, birthDay, gender, isYangYear);
const daeunList: DaeunPillar[] = [];