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 /notyet | |
parent | 29532bc4814051a842df34c05aa74b18dcfd5dea (diff) | |
download | notyet-163069ef871e57beb44c324bc166d2991b752ceb.tar.gz notyet-163069ef871e57beb44c324bc166d2991b752ceb.tar.xz notyet-163069ef871e57beb44c324bc166d2991b752ceb.zip |
add time stamp markers (+/-/!), inspired from howm
Diffstat (limited to 'notyet')
-rwxr-xr-x | notyet | 25 |
1 files changed, 24 insertions, 1 deletions
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 |