Last active
September 17, 2021 20:26
-
-
Save tbabej/e6c43b4e074d71abe3e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import pytz | |
from datetime import time | |
from tasklib.task import Task | |
LOCALTZ = pytz.timezone('Europe/Bratislava') # Your timezone | |
DEFAULT_TIME = time(22,0,0) # Your wanted default time | |
def is_local_midnight(timestamp): | |
return timestamp.astimezone(LOCALTZ).time() == time(0,0,0) | |
def set_default_time(timestamp): | |
return timestamp.astimezone(LOCALTZ).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']) | |
modified = True | |
else: | |
modified = False | |
print task.export_data() | |
if modified: | |
print "Default due time has been set." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The same, just symlink the files. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These scripts will change the behaviour of Taskwarrior or setting 00:00:00 as default time for a day to something else.
They are identical up to line 20, where modify=True needs to be set for on-modify script. Requires tasklib from my github repo, develop branch.