From 440b98d2aec6789c6bb9d1c7e766428096e412e5 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Thu, 15 Aug 2019 19:23:17 +0200 Subject: add defered timestamps with ~, inspired from howm --- README.md | 3 ++- notyet | 11 ++++++++++- 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 -- cgit 1.4.1