{"id":19621367,"url":"https://github.com/commenthol/date-chinese","last_synced_at":"2026-03-08T13:32:03.103Z","repository":{"id":45057344,"uuid":"69723493","full_name":"commenthol/date-chinese","owner":"commenthol","description":"Chinese Calendar","archived":false,"fork":false,"pushed_at":"2022-05-21T08:41:38.000Z","size":115,"stargazers_count":49,"open_issues_count":0,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T18:05:42.275Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/commenthol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-01T06:34:38.000Z","updated_at":"2025-03-27T07:15:06.000Z","dependencies_parsed_at":"2022-08-29T21:52:27.436Z","dependency_job_id":null,"html_url":"https://github.com/commenthol/date-chinese","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fdate-chinese","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fdate-chinese/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fdate-chinese/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fdate-chinese/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commenthol","download_url":"https://codeload.github.com/commenthol/date-chinese/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252798781,"owners_count":21805880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T11:22:40.996Z","updated_at":"2026-03-08T13:31:58.083Z","avatar_url":"https://github.com/commenthol.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# date-chinese\n\n\u003e Chinese Calendar\n\n[![NPM version](https://badge.fury.io/js/date-chinese.svg)](https://www.npmjs.com/package/date-chinese/)\n[![Build Status](https://github.com/commenthol/date-chinese/workflows/CI/badge.svg?branch=master\u0026event=push)](https://github.com/commenthol/date-chinese/actions/workflows/ci.yml?query=branch%3Amaster)\n\n\nChinese Calendar calculations with conversion from/ to Gregorian Date.\n\nThe module supports:\n\n- conversion from Gregorian Date to Chinese Date and vice versa\n- conversion from javascript Date object to Chinese Date and vice versa\n- conversion from JDE to Chinese Date and vice versa\n- calculation of chinese New Year for a given Gregorian year\n- calculation of Qı̄ngmíng pure brightness festival\n- calculation of solar terms (minor - Jiéqì / major - Zhōngqì)\n- calculations of Korean, Vietnamese Calendar based on the Chinese but using a different meridian\n- calculations of Japanese solar terms (sekki)\n\n**Note:** Some calculations may take quite some time (\u003e 40ms). Therefore\n`CalendarChinese` has a built in cache to store results of long running\ncalculations.\n\n\n## Table of Contents\n\n\u003c!-- !toc (minlevel=2 omit=\"Table of Contents\") --\u003e\n\n* [Usage](#usage)\n  * [Construct a new Chinese Date](#construct-a-new-chinese-date)\n  * [from Gregorian Date](#from-gregorian-date)\n  * [to Gregorian Date](#to-gregorian-date)\n  * [from Date](#from-date)\n  * [to Date](#to-date)\n  * [Chinese New Year](#chinese-new-year)\n  * [Qı̄ngmíng](#qı̄ngmíng)\n  * [Solar Terms](#solar-terms)\n* [Japanese Calendar](#japanese-calendar)\n  * [Sekki](#sekki)\n* [Korean Calendar](#korean-calendar)\n* [Vietnamese Calendar](#vietnamese-calendar)\n* [Contribution and License Agreement](#contribution-and-license-agreement)\n* [License](#license)\n* [References](#references)\n\n\u003c!-- toc! --\u003e\n\n## Usage\n\n### Construct a new Chinese Date\n\n**Parameters**\n\n**cycle**: `Number | Array | Object`, chinese 60 year cicle; if `{Array}` than `[cycle, year, ..., day]`  \n**year**: `Number`, chinese year in cycle  \n**month**: `Number`, chinese month  \n**leap**: `Number`, `true` if leap month  \n**day**: `Number`, chinese day\n\n\n```js\nconst CalendarChinese = require('date-chinese')\nlet cal = new CalendarChinese(78, 1, 10, true, 9)\ncal.get()\n//\u003e [ 78, 1, 10, true, 9 ]\n```\n\n`CalenderChinese` uses an internal cache for long running calculations.\nUse `set()` to reuse cached results.\n\n\n### from Gregorian Date\n\nThe timezone of the Gregorian Date is Chinese Standard Time (Beijing Time for years less than 1929).\n\n```js\nconst CalendarChinese = require('date-chinese')\nlet cal = new CalendarChinese()\ncal.fromGregorian(1984, 12,  1)\n\n// properties\ncal.cycle  //\u003e 78\ncal.year   //\u003e 1\ncal.month  //\u003e 10\ncal.leap   //\u003e true // is leap month\ncal.day    //\u003e 9\n\nlet [cycle, year, month, leap, day] = cal.get()\n//\u003e [ 78, 1, 10, true, 9 ]\n```\n\n### to Gregorian Date\n\nConvert Chinese Date back to Gregorian Date\n\n```js\nlet cal = new CalendarChinese(78, 1, 10, true, 9)\nlet gdate = cal.toGregorian()\n//\u003e { year: 1984, month: 12, day: 1 }\n```\n\n### from Date\n\nCalculate chinese calendar date from javascript Date object\n\n```js\nlet cal = new CalendarChinese()\nlet date = new Date('1984-12-01T00:00:00+08:00')\ncal.fromDate(date)\nlet cdate = cal.get()\n//\u003e [ 78, 1, 10, true, 9 ]\n```\n\n### to Date\n\n```js\nlet cal = new CalendarChinese(78, 1, 10, true, 9)\nlet date = cal.toDate(date).toISOString()\n//\u003e 1984-11-30T16:00:00.426Z\n```\n\n### Chinese New Year\n\n```js\nconst CalendarChinese = require('date-chinese')\n\nlet cal = new CalendarChinese()\nlet newYear = cal.newYear(1985)\ncal.fromJDE(newYear)\nlet cdate = cal.get()\n//\u003e [ 78, 2, 1, false, 1 ]\n\n// convert to Gregorian Date (Chinese Standard Time)\nlet gdate = cal.toGregorian()\n//\u003e { year: 1985, month: 2, day: 20 }\n\n// convert to Date\nlet date = cal.toDate()\n//\u003e 1985-02-19T16:00:00.306Z\n\n// convert to Date for more accurate and faster result\nconst julian = require('astronomia').julian\nlet date = new julian.CalendarGregorian().fromJDE(newYear).toDate()\n//\u003e 1985-02-19T16:00:00.000Z\n```\n\n### Qı̄ngmíng\n\nPure brightness festival date\n\n```js\nlet cal = new CalendarChinese()\nlet qm = cal.qingming(1985)\ncal.fromJDE(qm)\nlet cdate = cal.get()\n//\u003e [ 78, 2, 2, false, 16 ]\nlet gdate = cal.toGregorian()\n//\u003e { year: 1985, month: 4, day: 5 }\n```\n\nor using chinese cycle/ year\n\n```js\nlet cal = new CalendarChinese(78, 2)\nlet qm = cal.qingming()\ncal.fromJDE(qm)\nlet cdate = cal.get()\n//\u003e [ 78, 2, 2, false, 16 ]\nlet gdate = cal.toGregorian()\n//\u003e { year: 1985, month: 4, day: 5 }\n```\n\n### Solar Terms\n\n```js\nlet cal = new CalendarChinese()\nlet qm = cal.solarTerm(5, 1985)\ncal.fromJDE(qm)\nlet cdate = cal.get()\n//\u003e [ 78, 2, 2, false, 16 ]\nlet gdate = cal.toGregorian()\n//\u003e { year: 1985, month: 4, day: 5 }\n```\n\n#### Zhōngqì - Major Solar Terms\n\n```js\nlet cal = new CalendarChinese()\nlet qm = cal.majorSolarTerm(3, 1985)\ncal.fromJDE(qm)\nlet cdate = cal.get()\n//\u003e [ 78, 2, 3, false, 1 ]\nlet gdate = cal.toGregorian()\n//\u003e { year: 1985, month: 4, day: 20 }\n```\n\n#### Jiéqì - Minor Solar Terms\n\n```js\nlet cal = new CalendarChinese()\nlet qm = cal.minorSolarTerm(3, 1985)\ncal.fromJDE(qm)\nlet cdate = cal.get()\n//\u003e [ 78, 2, 2, false, 16 ]\nlet gdate = cal.toGregorian()\n//\u003e { year: 1985, month: 4, day: 5 }\n```\n\n## Japanese Calendar\n\nEpoch start for the Japanese Calendar in unknown. So Chinese Epoch in 2636 BCE is *wrongly* used.\n\n### Sekki\n\n```js\nconst CalendarJapanese = require('date-chinese').CalendarJapanese\nlet cal = new CalendarJapanese()\nlet qm = cal.solarTerm(1, 2016)\ncal.fromJDE(qm)\nlet gdate = cal.toGregorian()\n//\u003e { year: 2016, month: 2, day: 4 }\n```\n\n## Korean Calendar\n\nEpoch start in 2333 BCE\n\n```js\nconst CalendarKorean = require('date-chinese').CalendarKorean\nlet cal = new CalendarKorean(73, 13, 11, false, 25)\nlet gdate = cal.toGregorian()\n//\u003e { year: 2000, month: 1, day: 1 }\n```\n\n## Vietnamese Calendar\n\nEpoch start for the Vietnamese Calendar in unknown. So Chinese Epoch in 2636 BCE is maybe *wrongly* used.\n\n```js\nconst CalendarVietnamese = require('date-chinese').CalendarVietnamese\nlet cal = new CalendarVietnamese()\ncal.fromGregorian(1985,  3, 22)\nlet cdate = cal.get()\n//\u003e [ 78, 2, 2, true, 2 ]\nlet gyear = cal.yearFromEpochCycle()\n//\u003e 1985\n```\n\n## Contribution and License Agreement\n\nIf you contribute code to this project, you are implicitly allowing your\ncode to be distributed under the MIT license. You are also implicitly\nverifying that all code is your original work or correctly attributed\nwith the source of its origin and License.\n\n## License\n\nCopyright (c) 2016 commenthol (MIT License)\n\nSee [LICENSE][] for more info.\n\n## References\n\n\u003c!-- !ref --\u003e\n\n* [LICENSE][LICENSE]\n\n\u003c!-- ref! --\u003e\n\n[LICENSE]: ./LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fdate-chinese","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommenthol%2Fdate-chinese","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fdate-chinese/lists"}