https://github.com/hungtcs/traditional-chinese-calendar-database
:calendar: 中国农历数据库 1901~2100年
https://github.com/hungtcs/traditional-chinese-calendar-database
calendar calendar-events chinese-lunar-calendar lunar lunar-calendar lunar2solar solar2lunar traditional-chinese-calendar
Last synced: about 2 months ago
JSON representation
:calendar: 中国农历数据库 1901~2100年
- Host: GitHub
- URL: https://github.com/hungtcs/traditional-chinese-calendar-database
- Owner: hungtcs
- License: mit
- Created: 2020-06-12T07:25:51.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T00:15:20.000Z (about 2 years ago)
- Last Synced: 2025-01-04T09:44:53.398Z (5 months ago)
- Topics: calendar, calendar-events, chinese-lunar-calendar, lunar, lunar-calendar, lunar2solar, solar2lunar, traditional-chinese-calendar
- Language: TypeScript
- Homepage: https://hungtcs.github.io/traditional-chinese-calendar-database/examples/index.html
- Size: 9.56 MB
- Stars: 49
- Watchers: 2
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
农历数据库
====**数据来源于[香港天文台],请遵守相关协议使用。**
提供1901年至2100年的[公历]和[农历]日期对照,包含[二十四节气]、[星期]、[十二生肖]数据。
---
JSON文件由 [database/origin](database/origin) 中的文本文件解析转换来的,转换之后的数据我没有仔细校验,如果发现数据不准确,可以自己对原文件进行转换。
---
### 使用方式
```htmlimport { Database } from '../dist/index.esm.js';
const database = new Database();
database.load('../database/all.bin')
.then(data => {
const now = new Date();
const date = database.getCompoundDate(now.getFullYear(), now.getMonth() + 1, now.getDate());
document.querySelector('#content').innerHTML = `今天是:${ date.toString() }`;
document.querySelector('#json').innerHTML = `<pre>${ JSON.stringify(date, null, 2) }</pre>`;
});```
[示例](https://hungtcs.github.io/traditional-chinese-calendar-database/examples/index.html)
### 数据格式
#### database/all.json.zip
包含1901年到2100年的数据,使用zlib压缩,大小为639KB。
#### JSON源文件
- database/json
- database/json/minJSON数据以每年为一个独立的文件存储,内容格式为:
```typescript
{
// 星期
day: string,
// 公历日期
gregorian: {
year: number,
month: number,
date: number,
},
// 农历日期
lunar: {
year: string,
month: string,
date: string,
// 是否閏月
leapMonth: boolean,
},
// 生肖
zodiac: string,
// 节气
solarTerm: string,
}
```#### ZIP压缩的JSON源文件
使用`zlib`压缩的json文件,适合在浏览器端使用,体积较小,单个文件大约3.6KB。
浏览器端解压可使用[`pako`](https://github.com/nodeca/pako)库,
例子请查看:[browser-unzip.html](./examples/browser-unzip.html)[星期]: https://zh.wikipedia.org/wiki/%E6%98%9F%E6%9C%9F
[公历]: https://zh.wikipedia.org/wiki/%E6%A0%BC%E9%87%8C%E6%9B%86
[农历]: https://zh.wikipedia.org/zh/%E8%BE%B2%E6%9B%86
[十二生肖]: https://zh.wikipedia.org/wiki/%E7%94%9F%E8%82%96
[二十四节气]: https://zh.wikipedia.org/wiki/%E8%8A%82%E6%B0%94
[香港天文台]: https://www.hko.gov.hk/tc/index.html