
请输入您的出生日期(公元纪年):
javascript
const form = document.querySelector(‘form’);
form.addEventListener(‘submit’, (event) => {
event.preventDefault();
const year = Number(document.querySelector(‘year’).value);
const month = Number(‘6-21’: ‘夏至’,
‘7-7’: ‘小暑’,
‘7-22’: ‘大暑’,
‘8-7’: ‘立秋’,
‘8-23’: ‘处暑’,
‘9-7’: ‘白露’,
‘9-23’: ‘秋分’,
’10-8′: ‘寒露’,
’10-23′: ‘霜降’,
’11-7′: ‘立冬’,
’11-22′: ‘小雪’,
’12-7′: ‘大雪’,
’12-21′: ‘冬至’,
‘1-5’: ‘小寒’,
‘1-20’: ‘大寒’
};
const month = date.getMonth() + 1;
const day = date.getDate();
const key = `${month}-${day}`;
return solarTerms[key] || ”;
}
function getZodiacSign(date) {
const zodiacSigns = {
‘1-20’: ‘水瓶座’,
‘2-18’: ‘双鱼座’,
‘2-19’: ‘白羊座’,
‘3-20’: ‘金牛座’,
‘4-20’: ‘双子座’,
‘5-20’: ‘巨蟹座’,
‘6-21’: ‘狮子座’,
‘7-22’: ‘处女座’,
‘8-23’: ‘天秤座’,
‘9-22’: ‘天蝎座’,
’10-23′: ‘射手座’,
’11-22′: ‘摩羯座’,
’12-22′: ‘水瓶座’
};
const month = date.getMonth() + 1;
const day = date.getDate();
const key = `${month}-${day}`;
return zodiacSigns[key] || ”;
}
function getChineseZodiac(date) {
const chineseZodiacs = [‘鼠’, ‘牛’, ‘虎’, ‘兔’, ‘龙’, ‘蛇’, ‘马’, ‘羊’, ‘猴’, ‘鸡’, ‘狗’, ‘猪’];
const year = date.getFullYear();
const index = (year – 4) % 12;
return chineseZodiacs[index];
}