blob: ec2cc41f7d0d1b44a02618073778a464891c3e55 (
plain) (
blame)
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
|
#!/usr/bin/env python3
# Adopted from https://github.com/tbabej/task.default-date-time
from datetime import time
from tasklib import Task, local_zone
DEFAULT_TIME = time(22, 0, 0)
def is_local_midnight(timestamp):
return timestamp.astimezone(local_zone).time() == time(0, 0, 0)
def set_default_time(timestamp):
return timestamp.astimezone(local_zone).replace(
hour=DEFAULT_TIME.hour,
minute=DEFAULT_TIME.minute,
second=DEFAULT_TIME.second
)
task = Task.from_input()
if task['due'] and is_local_midnight(task['due']):
task['due'] = set_default_time(task['due'])
print("Default due time has been set.")
print(task.export_data())
|