Use a human readable format when editing dates on a task
This commit is contained in:
parent
14b28b767f
commit
9292befae4
1 changed files with 32 additions and 21 deletions
|
@ -301,6 +301,15 @@
|
||||||
(escaped (format "%s:\"%s\"" attribute new)))
|
(escaped (format "%s:\"%s\"" attribute new)))
|
||||||
(taskwarrior--mutable-shell-command "modify" id escaped)))
|
(taskwarrior--mutable-shell-command "modify" id escaped)))
|
||||||
|
|
||||||
|
(defun taskwarrior--change-date (date)
|
||||||
|
"Change a DATE on task."
|
||||||
|
(let* ((prefix (format "%s: " (capitalize date)))
|
||||||
|
(id (taskwarrior-id-at-point))
|
||||||
|
(task (taskwarrior-export-task id))
|
||||||
|
(old (taskwarrior--reformat-date (cdr (assoc-string date task))))
|
||||||
|
(new (read-from-minibuffer prefix old)))
|
||||||
|
(taskwarrior--mutable-shell-command "modify" id (format "%s:%s" date new))))
|
||||||
|
|
||||||
(defun taskwarrior-edit-tags ()
|
(defun taskwarrior-edit-tags ()
|
||||||
"Edit tags on task."
|
"Edit tags on task."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -448,33 +457,35 @@
|
||||||
(defun taskwarrior-set-due ()
|
(defun taskwarrior-set-due ()
|
||||||
"Set due date on task."
|
"Set due date on task."
|
||||||
(interactive)
|
(interactive)
|
||||||
(taskwarrior--change-attribute "due"))
|
(taskwarrior--change-date "due"))
|
||||||
|
|
||||||
(defun taskwarrior-set-scheduled ()
|
(defun taskwarrior-set-scheduled ()
|
||||||
"Set schedule date on task at point."
|
"Set schedule date on task at point."
|
||||||
(interactive)
|
(interactive)
|
||||||
(taskwarrior--change-attribute "scheduled"))
|
(taskwarrior--change-date "scheduled"))
|
||||||
|
|
||||||
(defun taskwarrior-set-wait ()
|
(defun taskwarrior-set-wait ()
|
||||||
"Set wait date on task at point."
|
"Set wait date on task at point."
|
||||||
(interactive)
|
(interactive)
|
||||||
(taskwarrior--change-attribute "wait"))
|
(taskwarrior--change-date "wait"))
|
||||||
|
|
||||||
(defun taskwarrior-set-untl ()
|
(defun taskwarrior-set-until ()
|
||||||
"Set until date on task at point."
|
"Set until date on task at point."
|
||||||
(interactive)
|
(interactive)
|
||||||
(taskwarrior--change-attribute "until"))
|
(taskwarrior--change-date "until"))
|
||||||
|
|
||||||
(define-transient-command taskwarrior-date ()
|
(define-transient-command taskwarrior-date ()
|
||||||
"Edit date on task"
|
"Edit date on task"
|
||||||
[["Date"
|
[["Date"
|
||||||
("d" "due" taskwarrior-set-due)
|
("d" "Due" taskwarrior-set-due)
|
||||||
("s" "scheduled" taskwarrior-set-scheduled)
|
("s" "Scheduled" taskwarrior-set-scheduled)
|
||||||
("w" "wait" taskwarrior-set-wait)
|
("w" "Wait" taskwarrior-set-wait)
|
||||||
("u" "until" taskwarrior-set-untl)]])
|
("u" "Until" taskwarrior-set-until)]])
|
||||||
|
|
||||||
(defun taskwarrior--reformat-date (twdate)
|
(defun taskwarrior--reformat-date (twdate)
|
||||||
"Reformat a taskwarrior TWDATE into a readable string."
|
"Reformat a taskwarrior TWDATE into a readable string."
|
||||||
|
(if (eq twdate nil)
|
||||||
|
nil
|
||||||
(let ((regex (rx
|
(let ((regex (rx
|
||||||
(seq
|
(seq
|
||||||
(submatch (= 4 digit))
|
(submatch (= 4 digit))
|
||||||
|
@ -493,7 +504,7 @@
|
||||||
(match-string 3 twdate)
|
(match-string 3 twdate)
|
||||||
(match-string 4 twdate)
|
(match-string 4 twdate)
|
||||||
(match-string 5 twdate)
|
(match-string 5 twdate)
|
||||||
(match-string 6 twdate)))))
|
(match-string 6 twdate))))))
|
||||||
|
|
||||||
(defun taskwarrior--parse-date (twdate)
|
(defun taskwarrior--parse-date (twdate)
|
||||||
(ts-parse (taskwarrior--reformat-date twdate)))
|
(ts-parse (taskwarrior--reformat-date twdate)))
|
||||||
|
|
Loading…
Reference in a new issue