From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: Re: tsia-up sorting strategy sorts agenda by date and ignores time. How can I change that? Date: Tue, 21 Mar 2017 12:13:02 -0500 Message-ID: <87shm6wo2p.fsf@fastmail.fm> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqNLK-0000z4-E6 for emacs-orgmode@gnu.org; Tue, 21 Mar 2017 13:13:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cqNLF-0004Ud-Bn for emacs-orgmode@gnu.org; Tue, 21 Mar 2017 13:13:10 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:45551) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cqNLE-0004UP-Gw for emacs-orgmode@gnu.org; Tue, 21 Mar 2017 13:13:05 -0400 In-Reply-To: (Arkady Grudzinsky's message of "Mon, 20 Mar 2017 11:43:33 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Arkady Grudzinsky Cc: emacs-orgmode@gnu.org Arkady Grudzinsky writes: > Hi, > > I'd like to sort my tasks in agenda by inactive creation > timestamp which includes the time portion. I have found that > tsia-up strategy ignores the time portion of the timestamp. Is > there a way to take time into account? Unfortunately, the org sorting relies on org-time-string-to-absolute, which converts time strings to days only, so the default is just a day to day comparison. You could use something like this and then add user-defined-up or user-defined-down where desired in org-agenda-sorting-strategy: --8<---------------cut here---------------start------------->8--- (defun my-sort-by-inactive-timestamp-incl-time (a b) (let* ((ma (get-text-property 1 'org-marker a)) (mb (get-text-property 1 'org-marker b)) (tsa (with-current-buffer (marker-buffer ma) (org-entry-get (marker-position ma) "TIMESTAMP_IA"))) (tsb (with-current-buffer (marker-buffer mb) (org-entry-get (marker-position mb) "TIMESTAMP_IA"))) (seca (if tsa (org-time-string-to-seconds tsa) 0)) (secb (if tsb (org-time-string-to-seconds tsb) 0))) (cond ((> seca secb) 1) ((> secb seca) -1) (t nil)))) (setq org-agenda-cmp-user-defined 'my-sort-by-inactive-timestamp-incl-time) --8<---------------cut here---------------end--------------->8--- I imagine there are ways to do this more elegantly (e.g., by iterating over a and b), but this gets the job done for me. Best, Matt