-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdateutil
More file actions
executable file
·30 lines (26 loc) · 1.23 KB
/
Copy pathdateutil
File metadata and controls
executable file
·30 lines (26 loc) · 1.23 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
#!/usr/bin/env python
import dateutil.parser
def report(s):
print("**************")
print(s)
ts = dateutil.parser.parse(s)
# Methods available to ts:
# ['__add__', '__class__', '__delattr__', '__dir__', '__doc__',
# '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__',
# '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__',
# '__ne__', '__new__', '__radd__', '__reduce__', '__reduce_ex__',
# '__repr__', '__rsub__', '__setattr__', '__sizeof__', '__str__',
# '__sub__', '__subclasshook__', 'astimezone', 'combine', 'ctime',
# 'date', 'day', 'dst', 'fold', 'fromisocalendar', 'fromisoformat',
# 'fromordinal', 'fromtimestamp', 'hour', 'isocalendar', 'isoformat',
# 'isoweekday', 'max', 'microsecond', 'min', 'minute', 'month',
# 'now', 'replace', 'resolution', 'second', 'strftime', 'strptime',
# 'time', 'timestamp', 'timetuple', 'timetz', 'today', 'toordinal',
# 'tzinfo', 'tzname', 'utcfromtimestamp', 'utcnow', 'utcoffset',
# 'utctimetuple', 'weekday', 'year']
print(ts)
print(f'epoch: {ts.timestamp()}')
print(f'tzinfo: {ts.tzinfo}')
report('2024-02-15T00:57:26.087-0800')
report('2024-02-15T00:57:26.087+0800')
report('2024-02-15T00:57:26.087')