unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 48133@debbugs.gnu.org
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	[thread overview]
Message-ID: <87pmyayibb.fsf@localhost> (raw)
In-Reply-To: <83k0oiany7.fsf@gnu.org>

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	other threads:[~2021-05-01  8:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-01  1:47 bug#48133: 28.0.50; [native-comp] time-to-days throws wrong-number-of-arguments error Ihor Radchenko
2021-05-01  6:33 ` Eli Zaretskii
2021-05-01  7:11   ` Ihor Radchenko
2021-05-01  7:54     ` Eli Zaretskii
2021-05-01  8:22       ` Ihor Radchenko [this message]
2021-05-01  8:27         ` Eli Zaretskii
2021-05-01 19:35         ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-02  7:18 ` Lars Ingebrigtsen
2021-05-02  7:43   ` Ihor Radchenko
2021-05-02  8:01     ` Lars Ingebrigtsen
2021-05-02  8:28       ` Ihor Radchenko
2021-05-02  8:27         ` Lars Ingebrigtsen
2021-05-02  8:40           ` Ihor Radchenko
2021-05-02  8:43             ` Lars Ingebrigtsen
2021-05-02 13:06       ` Ihor Radchenko
2021-05-02 13:04         ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmyayibb.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=48133@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).