emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is a week?


From: Max Nikulin
Subject: Re: What is a week?
Date: Mon, 24 Apr 2023 22:13:01 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0

On 24/04/2023 02:06, Marcin Borkowski wrote:

Fair enough.  Still, I consider this a bug in the docs (they don't say
clearly to set :wstart 7)...

I do not think :wstart 7 gives expected result when run on any day other than Sunday. Current expression shifts interval start into future, see the last column

#+begin_src elisp
(let ((dow-seq (number-sequence 0 6))
      (wstart-seq (number-sequence 0 7))
      (shift 0)
      (diff (lambda (dow ws) ; taken from org-clock.el:
              (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws))))))
  (cons (cons "dow\\wstart" wstart-seq)
        (mapcar
         (lambda (dow)
           (cons dow (mapcar (lambda (ws)
                               (funcall diff dow ws))
                             wstart-seq)))
         dow-seq)))
#+end_src

#+RESULTS:
| dow\wstart | 0 | 1 |  2 |  3 |  4 |  5 |  6 |  7 |
|          0 | 7 | 6 |  5 |  4 |  3 |  2 |  1 |  0 |
|          1 | 1 | 0 | -1 | -2 | -3 | -4 | -5 | -6 |
|          2 | 2 | 1 |  0 | -1 | -2 | -3 | -4 | -5 |
|          3 | 3 | 2 |  1 |  0 | -1 | -2 | -3 | -4 |
|          4 | 4 | 3 |  2 |  1 |  0 | -1 | -2 | -3 |
|          5 | 5 | 4 |  3 |  2 |  1 |  0 | -1 | -2 |
|          6 | 6 | 5 |  4 |  3 |  2 |  1 |  0 | -1 |

My expectation is values like in column "1" with appropriate cyclic shift.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]