A Chinese Calendar Library in Pure Python
=========================================
Chinese Calendar: http://en.wikipedia.org/wiki/Chinese_calendar
Usage
-----
>>> LunarDate.fromSolarDate(1976, 10, 1)
LunarDate(1976, 8, 8, 1)
>>> LunarDate(1976, 8, 8, 1).toSolarDate()
datetime.date(1976, 10, 1)
>>> LunarDate(1976, 8, 8, 1).year
1976
>>> LunarDate(1976, 8, 8, 1).month
8
>>> LunarDate(1976, 8, 8, 1).day
8
>>> LunarDate(1976, 8, 8, 1).isLeapMonth
True
>>> today = LunarDate.today()
>>> type(today).__name__
'LunarDate'
>>> # support '+' and '-' between datetime.date and datetime.timedelta
>>> ld = LunarDate(1976,8,8)
>>> sd = datetime.date(2008,1,1)
>>> td = datetime.timedelta(days=10)
>>> ld-ld
datetime.timedelta(0)
>>> (ld-sd).days
-11444
>>> ld-td
LunarDate(1976, 7, 27, 0)
>>> (sd-ld).days
11444
>>> ld+td
LunarDate(1976, 8, 18, 0)
>>> td+ld
LunarDate(1976, 8, 18, 0)
>>> ld2 = LunarDate.today()
>>> ld < ld2
True
>>> ld <= ld2
True
>>> ld > ld2
False
>>> ld >= ld2
False
>>> ld == ld2
False
>>> ld != ld2
True
>>> ld == ld
True
>>> LunarDate.today() == LunarDate.today()
True
>>> before_leap_month = LunarDate.fromSolarDate(2088, 5, 17)
>>> before_leap_month.year
2088
>>> before_leap_month.month
4
>>> before_leap_month.day
27
>>> before_leap_month.isLeapMonth
False
>>> leap_month = LunarDate.fromSolarDate(2088, 6, 17)
>>> leap_month.year
2088
>>> leap_month.month
4
>>> leap_month.day
28
>>> leap_month.isLeapMonth
True
>>> after_leap_month = LunarDate.fromSolarDate(2088, 7, 17)
>>> after_leap_month.year
2088
>>> after_leap_month.month
5
>>> after_leap_month.day
29
>>> after_leap_month.isLeapMonth
False
Limits
------
this library can only deal with year from 1900 to 2099 (in chinese calendar).
See also
--------
* lunar: http://packages.qa.debian.org/l/lunar.html,
A converter written in C, this program is derived from it.
* python-lunar: http://code.google.com/p/liblunar/
Another library written in C, including a python binding.
Raw data
{
"_id": null,
"home_page": "https://github.com/lidaobing/python-lunardate",
"name": "lunardate",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "LI Daobing",
"author_email": "lidaobing@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9c/50/86b2dc1ec6e97d952e17b3369473c62ec8fe1b90e1464898f681d7b15961/lunardate-0.2.1.tar.gz",
"platform": null,
"description": "\nA Chinese Calendar Library in Pure Python\n=========================================\n\nChinese Calendar: http://en.wikipedia.org/wiki/Chinese_calendar\n\nUsage\n-----\n >>> LunarDate.fromSolarDate(1976, 10, 1)\n LunarDate(1976, 8, 8, 1)\n >>> LunarDate(1976, 8, 8, 1).toSolarDate()\n datetime.date(1976, 10, 1)\n >>> LunarDate(1976, 8, 8, 1).year\n 1976\n >>> LunarDate(1976, 8, 8, 1).month\n 8\n >>> LunarDate(1976, 8, 8, 1).day\n 8\n >>> LunarDate(1976, 8, 8, 1).isLeapMonth\n True\n\n >>> today = LunarDate.today()\n >>> type(today).__name__\n 'LunarDate'\n\n >>> # support '+' and '-' between datetime.date and datetime.timedelta\n >>> ld = LunarDate(1976,8,8)\n >>> sd = datetime.date(2008,1,1)\n >>> td = datetime.timedelta(days=10)\n >>> ld-ld\n datetime.timedelta(0)\n >>> (ld-sd).days\n -11444\n >>> ld-td\n LunarDate(1976, 7, 27, 0)\n >>> (sd-ld).days\n 11444\n >>> ld+td\n LunarDate(1976, 8, 18, 0)\n >>> td+ld\n LunarDate(1976, 8, 18, 0)\n >>> ld2 = LunarDate.today()\n >>> ld < ld2\n True\n >>> ld <= ld2\n True\n >>> ld > ld2\n False\n >>> ld >= ld2\n False\n >>> ld == ld2\n False\n >>> ld != ld2\n True\n >>> ld == ld\n True\n >>> LunarDate.today() == LunarDate.today()\n True\n >>> before_leap_month = LunarDate.fromSolarDate(2088, 5, 17)\n >>> before_leap_month.year\n 2088\n >>> before_leap_month.month\n 4\n >>> before_leap_month.day\n 27\n >>> before_leap_month.isLeapMonth\n False\n >>> leap_month = LunarDate.fromSolarDate(2088, 6, 17)\n >>> leap_month.year\n 2088\n >>> leap_month.month\n 4\n >>> leap_month.day\n 28\n >>> leap_month.isLeapMonth\n True\n >>> after_leap_month = LunarDate.fromSolarDate(2088, 7, 17)\n >>> after_leap_month.year\n 2088\n >>> after_leap_month.month\n 5\n >>> after_leap_month.day\n 29\n >>> after_leap_month.isLeapMonth\n False\n\nLimits\n------\n\nthis library can only deal with year from 1900 to 2099 (in chinese calendar).\n\nSee also\n--------\n\n* lunar: http://packages.qa.debian.org/l/lunar.html,\n A converter written in C, this program is derived from it.\n* python-lunar: http://code.google.com/p/liblunar/\n Another library written in C, including a python binding.\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "A Chinese Calendar Library in Pure Python",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/lidaobing/python-lunardate"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4bcbff3dabf10e658970e67050bc76d3ddf180c44b9d9b4280ba8995f8e9db2e",
"md5": "831f9469e1697768f43e348ea80ab09b",
"sha256": "b4b4ba8855058266c436154946be8778cdfc3c45ac2956098454b66df2eaa644"
},
"downloads": -1,
"filename": "lunardate-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "831f9469e1697768f43e348ea80ab09b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 17913,
"upload_time": "2023-12-03T07:20:57",
"upload_time_iso_8601": "2023-12-03T07:20:57.256440Z",
"url": "https://files.pythonhosted.org/packages/4b/cb/ff3dabf10e658970e67050bc76d3ddf180c44b9d9b4280ba8995f8e9db2e/lunardate-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9c5086b2dc1ec6e97d952e17b3369473c62ec8fe1b90e1464898f681d7b15961",
"md5": "f1f5b4278aaccd69d6702aa30fa6ffe1",
"sha256": "f092417850973eb58e1eaee0c13dd50ab9d1cae35ed348ff5840e8e1e322fe6a"
},
"downloads": -1,
"filename": "lunardate-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "f1f5b4278aaccd69d6702aa30fa6ffe1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17456,
"upload_time": "2023-12-03T07:20:59",
"upload_time_iso_8601": "2023-12-03T07:20:59.276708Z",
"url": "https://files.pythonhosted.org/packages/9c/50/86b2dc1ec6e97d952e17b3369473c62ec8fe1b90e1464898f681d7b15961/lunardate-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-03 07:20:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lidaobing",
"github_project": "python-lunardate",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "lunardate"
}