-
Notifications
You must be signed in to change notification settings - Fork 12
/
Python08_Date_and_Time
58 lines (46 loc) · 1.37 KB
/
Python08_Date_and_Time
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## Python
## Date and Time
## Calendar Module
# Enter your code here. Read input from STDIN. Print output to STDOUT
# # Option 1
# import calendar
# month, day, year = map(int, input().split())
# print(list(calendar.day_name)[calendar.weekday(year, month, day)].upper())
# Option 2
import datetime
month, day, year = map(int, input().split())
print( datetime.datetime(year, month, day).strftime('%A').upper() )
# Option 2a
from datetime import datetime
month, day, year = map(int, input().split())
print( datetime(year, month, day).strftime('%A').upper() )
# # Option 3
# import calendar
# week_list = list(calendar.day_name)
# month, day, year = map(int, input().split())
# result = calendar.weekday(year, month, day)
# print((week_list[result]).upper())
## Time Delta
import math
import os
import random
import re
import sys
# Complete the time_delta function below.
from datetime import datetime as dt
def time_delta(t1, t2):
fmt = '%a %d %b %Y %H:%M:%S %z' #day dd mon yyyy hh mm ss utc
t1 = dt.strptime(t1, fmt)
t2 = dt.strptime(t2, fmt)
result = (int( abs((t1 - t2).total_seconds()) ))
return str(result)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
t = int(input())
for t_itr in range(t):
t1 = input()
t2 = input()
delta = time_delta(t1, t2)
fptr.write(delta + '\n')
fptr.close()
## end ##