Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ For default task date time of 21:30, it should look as follows:
DEFAULT_TIME = time(21,30,0) # Your wanted default time
```

Alternatively, configure the default due time (`HH:MM` format) in your `.taskrc` as follows:

```
task config default.duetime 21:30
```

Example of usage
----------------

Expand Down
9 changes: 5 additions & 4 deletions pirate_add_default_time.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/usr/bin/python
from __future__ import print_function
from datetime import datetime, time
from tasklib import Task
from tasklib import Task, TaskWarrior

DEFAULT_TIME = time(22,0,0) # Your wanted default time
tw = TaskWarrior()
local_zone = datetime.now().astimezone().tzinfo

DEFAULT_TIME = datetime.strptime(tw.config.get("default.duetime", "22:00"), "%H:%M")

def is_local_midnight(timestamp):
local_zone = datetime.now().astimezone().tzinfo
return timestamp.astimezone(local_zone).time() == time(0,0,0)

def set_default_time(timestamp):
local_zone = datetime.now().astimezone().tzinfo
return timestamp.astimezone(local_zone).replace(
hour=DEFAULT_TIME.hour,
minute=DEFAULT_TIME.minute,
Expand Down