-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmake_string.py
More file actions
29 lines (19 loc) · 1.15 KB
/
make_string.py
File metadata and controls
29 lines (19 loc) · 1.15 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
27
28
29
from datetime import datetime
def epoch(time_string):
return (datetime.strptime(time_string[:-6], "%Y-%m-%dT%H:%M:%S") - datetime(2017, 1, 1)).total_seconds()
def is_after_today(time_string):
return 0. < ((datetime.strptime(time_string[:-6], "%Y-%m-%dT%H:%M:%S") - datetime.today()).total_seconds())
def tweet_text(booking):
society = (booking["contact"].split("- ")[1])
start = datetime.strptime(booking["start_time"][:-6], "%Y-%m-%dT%H:%M:%S")
return "{} just booked {} for {}".format(society, booking['roomname'], start.strftime("%A %d %B at %H:%M"))
def next_booking(booking):
society = (booking["contact"].split("- ")[1])
start = datetime.strptime(booking["start_time"][:-6], "%Y-%m-%dT%H:%M:%S")
return "The next booking for {} is on {} in {}".format(society, start.strftime("%A %d %B at %H:%M"),
booking['roomname'])
if __name__ == "__main__":
print(is_after_today("2018-08-27T23:00:00+01:00"))
dtsecs = (datetime.strptime("2017-08-27T23:00:00+01:00"[:-6], "%Y-%m-%dT%H:%M:%S") - datetime.today()).total_seconds()
print(dtsecs)
print(bool(int(dtsecs)))