Created
August 15, 2021 06:35
-
-
Save abbasEbadian/7f2206fb997c1db3bc13a960b854bb3d to your computer and use it in GitHub Desktop.
پیدا کردن روزهای تعطیل تقویم با پایتون - Get holidays of jalali calendar
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
################################## | |
# author: [email protected] # | |
################################## | |
import requests | |
import datetime, jdatetime | |
today = datetime.datetime.now() | |
eid = datetime.datetime(2022, 3, 20) # 29 esfand 1400 | |
dates = [] | |
while today < eid: | |
date = today.strftime("%Y-%m-%d") | |
a = requests.get("https://pholiday.herokuapp.com/gdate/"+date) | |
if a.json().get("isHoliday") : | |
dates.append(jdatetime.datetime.fromgregorian(datetime=today).strftime("%Y,%-m,%d")) | |
today += datetime.timedelta(days=1) | |
print(dates) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi. it's a day early (on lunar holidays). any suggestions?
{"events":[{"isHoliday":true,"event":"شهادت امام رضا علیه السلام"}],"isHoliday":true,"date":"1401-7-4","gdate":"2022-9-26"}
the date is correct but the holiday is tomorrow.