-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdate.py
More file actions
24 lines (21 loc) · 765 Bytes
/
date.py
File metadata and controls
24 lines (21 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from utility import *
class Date:
def __init__(self, base: str, target: str, date: str,
occasion: str = ""):
self.base = base
self.target = target
self.date = date
self.y, self.m, self.d = split_date(date)
self.occasion = occasion
def get_occasion_date(self):
p = os.path.dirname(os.path.abspath(__file__))
f = os.path.join(p, "shamsi_events.csv")
df = pd.read_csv(f, encoding="utf-8")
temp = df[df["event"].str.contains(self.occasion)]
shamsi_date = convert_date(self.date, self.base, "shamsi")
y, m, d = map(int, split_date(shamsi_date))
ans = temp[temp["year"] == y].iloc[0]
date = datetime(year=ans["year"],
month=ans["month"],
day=ans["day"]).strftime("%Y-%m-%d")
return date