about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2019-08-15 19:23:17 +0200
committerLeah Neukirchen <leah@vuxu.org>2019-08-15 19:23:17 +0200
commit440b98d2aec6789c6bb9d1c7e766428096e412e5 (patch)
treec1a6ba42fcbc60dc4660e586f4fe01bb4c111970
parent163069ef871e57beb44c324bc166d2991b752ceb (diff)
downloadnotyet-440b98d2aec6789c6bb9d1c7e766428096e412e5.tar.gz
notyet-440b98d2aec6789c6bb9d1c7e766428096e412e5.tar.xz
notyet-440b98d2aec6789c6bb9d1c7e766428096e412e5.zip
add defered timestamps with ~, inspired from howm HEAD master
-rw-r--r--README.md3
-rwxr-xr-xnotyet11
2 files changed, 12 insertions, 2 deletions
diff --git a/README.md b/README.md
index eb69ed7..57f7bca 100644
--- a/README.md
+++ b/README.md
@@ -32,13 +32,14 @@ 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:
+After such a time stamp, there are four 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.
+* `~`: a deferred task, which will sink and raise in 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 9723e8e..711c0df 100755
--- a/notyet
+++ b/notyet
@@ -12,6 +12,7 @@ require 'time'
 
 TODAY = Date.today
 NOW = Time.now
+DEFER_DAYS = 14
 
 class Entry < Struct.new(:depth, :state, :desc, :file, :line, :children)
   def reindent(change)
@@ -56,7 +57,7 @@ class Entry < Struct.new(:depth, :state, :desc, :file, :line, :children)
   end
 
   def dateorder
-    if desc =~ /^(?:\(.*?\)\s*)?\[(\d\d\d\d-\d\d-\d\d)( \d\d:\d\d)?\]([+!-]?)/
+    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
@@ -69,6 +70,14 @@ class Entry < Struct.new(:depth, :state, :desc, :file, :line, :children)
         else
           Float::INFINITY
         end
+      when "~"        # defer, sink and raise periodically
+        if NOW < d
+          d - NOW
+        else
+          # sawtooth function
+          (DEFER_DAYS -
+           (((TODAY - d.to_date) % (2*DEFER_DAYS)) - DEFER_DAYS).abs) * 24*60*60
+        end
       end
     else
       Float::INFINITY