From e4f9ee8d25273f75d969cded84019baea07883f7 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 14 Dec 2023 02:22:11 +0200 Subject: Add #'(gnosis-current-date) Get current date in (yyyy mm dd) & add offset. Inspired by calendar-current-date func Changed format to (year month day) --- gnosis.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gnosis.el b/gnosis.el index 6fbaf5b..ff5085e 100644 --- a/gnosis.el +++ b/gnosis.el @@ -236,6 +236,19 @@ Used to calcuate new interval for failed questions." :group 'gnosis :type 'float) +(defun gnosis-current-date (&optional offset) + "Return the current date in a list (year month day). +Optional integer OFFSET is a number of days from the current date." + (let* ((now (decode-time)) + (now (list (decoded-time-month now) + (decoded-time-day now) + (decoded-time-year now)))) + (let ((date (if (zerop (or offset 0)) + now + (calendar-gregorian-from-absolute + (+ offset (calendar-absolute-from-gregorian now)))))) + (list (nth 2 date) (nth 0 date) (nth 1 date))))) + (defun gnosis-calculate-e-factor (ef quality) "Calculate new e-factor given existing EF and binary QUALITY, 0 or 1." (cond -- cgit v1.2.3