bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#48133: 28.0.50; [native-comp] time-to-days throws wrong-number-of-ar


From: Ihor Radchenko
Subject: bug#48133: 28.0.50; [native-comp] time-to-days throws wrong-number-of-arguments error
Date: Sat, 01 May 2021 16:22:32 +0800

Eli Zaretskii <eliz@gnu.org> writes:

> So maybe the problem is not in time-date.el, maybe it's elsewhere?
> Can you show the exact code of the test that fails and how to run it?

I run it by cloning Org mode repo from
https://code.orgmode.org/bzg/org-mode.git
and running =make test=

The failing test is test-org/deadline-close-p failing at the first
should assertion:

(ert-deftest test-org/deadline-close-p ()
  "Test `org-deadline-close-p' specifications."
  (org-test-at-time "2016-06-03 Fri 01:43"
    ;; Timestamps are close if they are within `ndays' of lead time.
    (org-test-with-temp-text "* Heading"
      (should (org-deadline-close-p "2016-06-03 Fri" 0))
      (should (org-deadline-close-p "2016-06-02 Thu" 0))
      (should-not (org-deadline-close-p "2016-06-04 Sat" 0))
      (should (org-deadline-close-p "2016-06-04 Sat" 1))
      (should (org-deadline-close-p "2016-06-03 Fri 12:00" 0)))
    ;; Read `ndays' from timestamp if argument not given.
    (org-test-with-temp-text "* H"
      (should (org-deadline-close-p "2016-06-04 Sat -1d"))
      (should-not (org-deadline-close-p "2016-06-04 Sat -0d"))
      (should (org-deadline-close-p "2016-06-10 Fri -1w"))
      (should-not (org-deadline-close-p "2016-06-11 Sat -1w")))
    ;; Prefer `ndays' argument over lead time in timestamp.
    (org-test-with-temp-text "* H"
      (should (org-deadline-close-p "2016-06-04 Sat -0d" 1))
      (should-not (org-deadline-close-p "2016-06-04 Sat -0d" 0)))
    ;; Completed tasks are never close.
    (let ((org-todo-keywords '(("TODO" "|" "DONE"))))
      (org-test-with-temp-text "* TODO Heading"
        (should (org-deadline-close-p "2016-06-03")))
      (org-test-with-temp-text "* DONE Heading"
        (should-not (org-deadline-close-p "2016-06-03"))))))

org-deadline-close-p code:

(defun org-deadline-close-p (timestamp-string &optional ndays)
  "Is the time in TIMESTAMP-STRING close to the current date?"
  (setq ndays (or ndays (org-get-wdays timestamp-string)))
  (and (<= (org-time-stamp-to-now timestamp-string) ndays)
       (not (org-entry-is-done-p))))

org-time-stamp-to-now:

(defun org-time-stamp-to-now (timestamp-string &optional seconds)
  "Difference between TIMESTAMP-STRING and now in days.
If SECONDS is non-nil, return the difference in seconds."
  (let ((fdiff (if seconds #'float-time #'time-to-days)))
    (- (funcall fdiff (org-time-string-to-time timestamp-string))
       (funcall fdiff nil))))






reply via email to

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