Skip to content

Instantly share code, notes, and snippets.

@hosseinmasoomi
Created November 4, 2023 20:46
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hosseinmasoomi/0d5f873ec54e5538d3f46264c82d4126 to your computer and use it in GitHub Desktop.
Save hosseinmasoomi/0d5f873ec54e5538d3f46264c82d4126 to your computer and use it in GitHub Desktop.
api persian - shamsi calendar - holidays
Array.from(document.querySelectorAll("li[class='eventHoliday ']"), (node => ({
date:document.querySelector("input[type='text']").value +'/' + (Array.from(document.querySelectorAll("div[class='col-md-12']>div>div>span>span>span"), node => node.innerText).findIndex(x => x === node.innerText.split(" ")[1]) + 1).toString() + "/" + node.innerText.split(" ")[0].replace(/[۰-۹]/g, d => '۰۱۲۳۴۵۶۷۸۹'.indexOf(d)),
description: node.innerText.split(" ").slice(2).join(" ")
})))
@hosseinmasoomi
Copy link
Author

اسکریپت بالا را در سایت time.ir در کنسول اجرا کنید و به صورت استاتیک تعطیلات هر سال شمسی را همراه با توضیحات داشته باشید

@mdbaniani
Copy link

thanks for your efforts. you claim that this script returns holidays for a year but it only returns holidays displayed in the specific page (the month displayed) . also the dates are not well formatted.

example:

[
{
"date": "/1/5",
"description": "ولادت امام علی علیه السلام و روز پدر [ ١٣ رجب ]"
},
{
"date": "/1/19",
"description": "مبعث رسول اکرم (ص) [ ٢٧ رجب ]"
},
{
"date": "/1/22",
"description": "پیروزی انقلاب اسلامی"
}
]

@that-hossein
Copy link

@mdbaniani you should run script in this url that is the yearly view of calendar, to get holidays for a year

@mdbaniani
Copy link

@mdbaniani you should run script in this url that is the yearly view of calendar, to get holidays for a year

thx for clarifying

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