forked from CMSCompOps/SiteReadiness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeInfo.py
26 lines (24 loc) · 1.08 KB
/
TimeInfo.py
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
from datetime import date
class TimeInfo:
def __init__(self):
self.todaydate = date.today()
self.today = datetime.datetime.utcnow()
self.todaystamp = self.today.strftime("%Y-%m-%d")
self.todaystampfile = self.today.strftime("%Y-%m-%d %H:%M:%S")
self.todaystampfileSSB = self.today.strftime("%Y-%m-%d 00:00:01")
self.d = datetime.timedelta(1);
self.yesterday = self.today - self.d
self.yesterdaystamp = self.yesterday.strftime("%Y-%m-%d")
self.yesterdaystampfileSSB = self.yesterday.strftime("%Y-%m-%d 00:00:01")
self.timestamphtml = self.today.strftime("%Y%m%d")
# return a generator for iterating from start date to stop date
def daterange(start, stop, step=datetime.timedelta(days=1)):
if step.days > 0:
while start < stop:
yield start
start = start + step
elif step.days < 0:
while start > stop:
yield start
start = start + step