Skip to content

Instantly share code, notes, and snippets.

@tbabej
Last active September 17, 2021 20:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbabej/e6c43b4e074d71abe3e5 to your computer and use it in GitHub Desktop.
Save tbabej/e6c43b4e074d71abe3e5 to your computer and use it in GitHub Desktop.
#!/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."
The same, just symlink the files.
@tbabej
Copy link
Author

tbabej commented Jan 8, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment