Skip to content

Commit a2166ba

Browse files
committed
Days 1-3: Datetimes and Pomodoro
1 parent 3ac6cee commit a2166ba

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from datetime import date, timedelta
2+
3+
start_100days = date(2017, 3, 30)
4+
pybites_founded = date(2016, 12, 19)
5+
pycon_date = date(2018, 5, 8)
6+
end_100days = timedelta(days=100)
7+
8+
9+
def get_hundred_days_end_date():
10+
return start_100days + end_100days
11+
12+
13+
14+
def get_days_between_pb_start_first_joint_pycon():
15+
"""Return the int number of days"""
16+
17+
18+
print(get_hundred_days_end_date())
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'''Extract datetimes from log entries and calculate the time
2+
between the first and last shutdown events'''
3+
from datetime import datetime
4+
import os
5+
import urllib.request
6+
7+
SHUTDOWN_EVENT = 'Shutdown initiated'
8+
9+
# prep: read in the logfile
10+
logfile = os.path.join('/tmp', 'log')
11+
urllib.request.urlretrieve('http://bit.ly/2AKSIbf', logfile)
12+
13+
with open(logfile) as f:
14+
loglines = f.readlines()
15+
16+
17+
print(SHUTDOWN_EVENT in logfile)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from datetime import datetime
2+
from datetime import timedelta
3+
import time
4+
5+
def countdown(t):
6+
while t:
7+
mins, secs = divmod(t, 60)
8+
timeformat = '{:02d}:{:02d}'.format(mins, secs)
9+
print(timeformat, end='\r')
10+
time.sleep(60)
11+
t -= 1
12+
13+
now = datetime.now()
14+
nowPlusOne = now + timedelta(minutes = 25)
15+
16+
nowMinute = now.minute
17+
nowPlusOneMin = nowPlusOne.minute
18+
19+
while (nowMinute != nowPlusOneMin):
20+
time.sleep(1)
21+
now = datetime.now()
22+
nowMinute = now.minute
23+
print("Break time will be at: " + str(nowPlusOne))
24+
countdown(25)
25+
26+
27+
28+
print("Take a break!")
29+

0 commit comments

Comments
 (0)