-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathobjects.py
More file actions
26 lines (23 loc) · 1.07 KB
/
Copy pathobjects.py
File metadata and controls
26 lines (23 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import datetime as dt
from typing import List, Dict, Union
from collections import UserList
class DiningOffer:
def __init__(self,name:str,offer_dict:Dict,party_size:int):
time = offer_dict['time']
datetime = offer_dict.get("datetime",offer_dict.get("dateTime"))
self.name: str = name
self.datetime: dt.datetime = (dt.datetime
.strptime(datetime,r'%Y-%m-%dT%H:%M:%S%z'))
self.date: dt.date = self.datetime.date()
self.time = (dt.datetime.strptime(time,r'%H:%M')
.strftime(r'%I:%M %p'))
self.dow: str = self.date.strftime(r'%a')
self.month_short: str = self.date.strftime(r'%b')
self.day: str = self.date.strftime(r'%d')
self.party_size = party_size
def __repr__(self) -> str:
dow = self.datetime.strftime(r'%a')
month = self.datetime.strftime(r'%B')
day = self.datetime.strftime(r'%d')
year = self.datetime.year
return f'DiningOffer({self.name}: {self.time}, {dow} {month} {day} {year})'