Skip to content

Instantly share code, notes, and snippets.

@abbasEbadian
Created August 15, 2021 06:35
Show Gist options
  • Save abbasEbadian/7f2206fb997c1db3bc13a960b854bb3d to your computer and use it in GitHub Desktop.
Save abbasEbadian/7f2206fb997c1db3bc13a960b854bb3d to your computer and use it in GitHub Desktop.
پیدا کردن روزهای تعطیل تقویم با پایتون - Get holidays of jalali calendar
##################################
# 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)
@Aquarii
Copy link

Aquarii commented Sep 25, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment