Created
October 7, 2022 02:02
-
-
Save Lonenso/662e8bb40f07b024d2bcbdc4347b96ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zhdate import ZhDate | |
from datetime import datetime | |
def nextYear(date): | |
date = datetime(date.year + 1, date.month, date.day) | |
zhDate = ZhDate.from_datetime(date) | |
return date, zhDate | |
def matched(date, zhDate, orignalDate, originalZhDate): | |
month = date.month == orignalDate.month and zhDate.lunar_month == originalZhDate.lunar_month | |
day = date.day == originalDate.day and zhDate.lunar_day == originalZhDate.lunar_day | |
return month and day | |
while True: | |
dateStr = input("please input date(1900-01-01):") | |
date = datetime.strptime(dateStr, "%Y-%m-%d") | |
zhDate = ZhDate.from_datetime(date) | |
originalDate = date | |
originalZhDate = zhDate | |
print(originalDate.date(), originalZhDate) | |
i = 0 | |
while i < 100: | |
date, zhDate = nextYear(date) | |
if matched(date, zhDate, originalDate, originalZhDate): | |
print(date.date(), zhDate) | |
i += 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
requirements:
pip install zhdate