Patrick Williams | 215c1c3 | 2022-01-06 20:26:26 -0600 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 2 | from enum import Enum |
| 3 | from datetime import datetime, timezone |
| 4 | |
| 5 | |
| 6 | class TimeOfDay(Enum): |
| 7 | AM = 0 |
| 8 | PM = 1 |
| 9 | |
| 10 | |
| 11 | def timestamp(date: str, time: TimeOfDay) -> int: |
| 12 | [year, month, day] = [int(x) for x in date.split("-")] |
| 13 | |
| 14 | if time == TimeOfDay.AM: |
| 15 | [hour, minute, second] = [00, 00, 00] |
| 16 | else: |
| 17 | [hour, minute, second] = [23, 59, 59] |
| 18 | |
| 19 | return int( |
| 20 | datetime( |
| 21 | year, month, day, hour, minute, second, tzinfo=timezone.utc |
| 22 | ).timestamp() |
| 23 | ) |