diff options
author | Leah Neukirchen <leah@vuxu.org> | 2019-08-15 19:09:55 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2019-08-15 19:09:55 +0200 |
commit | 163069ef871e57beb44c324bc166d2991b752ceb (patch) | |
tree | edf72cfc45e83ff657c53f2c2b4a9dc0ca14c50e | |
parent | 29532bc4814051a842df34c05aa74b18dcfd5dea (diff) | |
download | notyet-163069ef871e57beb44c324bc166d2991b752ceb.tar.gz notyet-163069ef871e57beb44c324bc166d2991b752ceb.tar.xz notyet-163069ef871e57beb44c324bc166d2991b752ceb.zip |
add time stamp markers (+/-/!), inspired from howm
-rw-r--r-- | README.md | 7 | ||||
-rwxr-xr-x | notyet | 25 |
2 files changed, 31 insertions, 1 deletions
diff --git a/README.md b/README.md index a522577..eb69ed7 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,13 @@ I recommend using two spaces for each level. Additionally, a task can have an assigned date if it starts with the ISO format `[YYYY-MM-DD]` or `[YYYY-MM-DD HH:MM]`. +After such a time stamp, there are three possible markers: + +* `+` (or none): a task to be done until this date, priorized by date, + i.e. stays on top priority after the date. +* `-`: a reminder for this date, ordered by *days* to/past the date, + i.e. priority sinks after the date. +* `!`: a task with a hard deadline, with lowest priority after the date. When you run notyet, it will read the task file (by default `~/.notyet`, use `-f` to override) and *aggregate the tasks*: diff --git a/notyet b/notyet index c499aba..9723e8e 100755 --- a/notyet +++ b/notyet @@ -8,7 +8,10 @@ require 'optionparser' require 'date' +require 'time' + TODAY = Date.today +NOW = Time.now class Entry < Struct.new(:depth, :state, :desc, :file, :line, :children) def reindent(change) @@ -49,7 +52,27 @@ class Entry < Struct.new(:depth, :state, :desc, :file, :line, :children) def sort children.each { |c| c.sort } - children.sort_by! { |c| [c.state, c.desc] } + children.sort_by! { |c| [c.state, c.dateorder, c.desc] } + end + + def dateorder + if desc =~ /^(?:\(.*?\)\s*)?\[(\d\d\d\d-\d\d-\d\d)( \d\d:\d\d)?\]([+!-]?)/ + d = Time.parse("#{$1}#{$2}") + case $3 + when "+", "" # todo (default) = earliest first + d - NOW + when "-" # reminder = sort by difference to now + (d - NOW).abs + when "!" # deadline, drop after the time + if NOW < d + d - NOW + else + Float::INFINITY + end + end + else + Float::INFINITY + end end def propagate |