From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id GBJVDTbVoGUQEAEAkFu2QA (envelope-from ) for ; Fri, 12 Jan 2024 06:59:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id wAyfBzbVoGXuFwAAe85BDQ (envelope-from ) for ; Fri, 12 Jan 2024 06:59:18 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Iuvxt6+4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1705039157; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=oU2FGdECzWp4TLpvUJ09lImkV8sU4dn0BwKOMO/gkjg=; b=BgqqpkhB53PLu+OoWuQxDcfnNYVq8RBZ9opwYh8ZPGW17cmdqKubTwH85mtnXjBKZ/NJgM P+IFoiJw1Hk4zRmNFT/0QdpYNXb7q25Z9Fy+Bo28fdvv2Ro/NeoNI1C6U+vI4uFka7yDO3 62pHA6s7LI8h2RHKy6FNYUwdz8X3Orxw4DxGMdkr7cv+lePl0UgCw7ecaZPVaq6pAq7NJw w3YYcGq32oeO5zG0oVL5z63y5MKEwGz+aax+8r6YxNZlwIBQzxaHk7rvwsAxWH2GEJhmNL DP04WfrO36xByHAYodGkTChfVYbVusG++Uuo35/QCfbF5GH3JOZdf/eiNrNHuw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Iuvxt6+4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1705039157; a=rsa-sha256; cv=none; b=k/rR8pwSBYBfHqagkhgUgOxuth1iSpQeVo39Vf8RgzjBEWpuh/kMTDY64SUnPDOoqNIt7a 1UMO3DGcWOksR5yT5clyo5sGu+3bGddGv322cN9h7KzHKwJomz9kL6BDvDwlx2OMx4qw1g lDdEW16xymBRXJYhP0sxa4Rq+gHJN/+oLEfNG/OLObdUwEJN01x9lJuwkEtQDlrebYM3r/ P4vFyGLzbQhukSk952Hg0ysGMoyswEANcQCOYrAR1ROMu+gVLSi1tz7Mn5VEcgvcyTX6x9 19HlNZltgzEWPCsa+6mk4KVeJmDyUVkMyPV5n9GgmrqI26bCUWutkv7H+Vcarw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 913651056C for ; Fri, 12 Jan 2024 06:59:17 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOAYW-0003ku-Ka; Fri, 12 Jan 2024 00:58:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rOAYV-0003kg-1H for emacs-orgmode@gnu.org; Fri, 12 Jan 2024 00:58:11 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rOAYT-0008RG-AV for emacs-orgmode@gnu.org; Fri, 12 Jan 2024 00:58:10 -0500 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-28b93b04446so1296553a91.0 for ; Thu, 11 Jan 2024 21:58:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705039087; x=1705643887; darn=gnu.org; h=mime-version:user-agent:message-id:date:mail-followup-to:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=oU2FGdECzWp4TLpvUJ09lImkV8sU4dn0BwKOMO/gkjg=; b=Iuvxt6+4IxXObhQr0oNooGqi3kaIvWkfdvwRTwKu3wF5XPXSshWSXnzDxgdjQsO2HP CaoJ+eMfSrKIyh2sJpkWfeVnBkNP8cnrLVNEdRicnFyB6gZ9jOJ4BNsEoyUO/Zoo1i3U DKNEPzMJSrTK5XR92pr3dMcCnOuYbAqPNJZPMbikpBmTwVzYyxYgdcKaDAn15D/JhH69 SM0fSv9oUseyhTpJ/r11QL048pDhuV9gnNUHoxjkkPnET3GmaFpiLV9rRqVNrADhJeYX CV1dAcM7Gc16s34IFjkE7kOTz5e/3EiHoSnLeTkucckRZjSYYnexTc/7JQ1QC9KM5Xnb 3t3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705039087; x=1705643887; h=mime-version:user-agent:message-id:date:mail-followup-to:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oU2FGdECzWp4TLpvUJ09lImkV8sU4dn0BwKOMO/gkjg=; b=jPYRyNu2p6K9YZmkhYva0D9sUEcO48XbauSvkrTfE+TAEy83m7AEwRR82ZSHWf1ckB 8Z20OvxARb0ERPrXeYAazPR+iMQyvi0WupaeX26KIbHkwNZWecHTOHxdygGnMzNtW8MH +EJVe37TJ0q95Ek0Hm2H5V1vLNYonHbQEzyAjVRtdZtiuJ4TvijJydbsPPrJ/eLUqrgG eNbWrPEUnYLObhjI7fADg7gNVDVqKaT9MAtxH8WgsmsWSxHUeV1lAYyIxgKS2NwtY2iH +HpiO0KBUpVb9dXoAVvCgsQFWrA8q21878zkGWmnLSMpX+lYupG4h3afJOUPsuHKxRr8 pagw== X-Gm-Message-State: AOJu0YwyIG5TLPUMdmuYh0omx4aPjzMJE8+bGvS5RZarG0mAS7kKgqHR ATfPff+r0rudaCqiPhD123rqVg3RaH4= X-Google-Smtp-Source: AGHT+IGjud56d8uOeKiel2pjzmN0tYu/geb1bQD+hYG3Pmz8IeolaCKzMJUcQbf356AqxGPLknQhtQ== X-Received: by 2002:a17:902:d50e:b0:1d4:e2bc:891c with SMTP id b14-20020a170902d50e00b001d4e2bc891cmr811385plg.5.1705039087091; Thu, 11 Jan 2024 21:58:07 -0800 (PST) Received: from localhost ([209.52.88.83]) by smtp.gmail.com with ESMTPSA id jc22-20020a17090325d600b001d5a79547cdsm306090plb.131.2024.01.11.21.58.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 21:58:06 -0800 (PST) From: David Rogers To: Org-mode list Subject: Diary sexp and comparing dates, agenda Mail-Followup-To: Org-mode list Date: Thu, 11 Jan 2024 21:58:05 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; format=flowed Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=davidandrewrogers@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx12.migadu.com X-Migadu-Queue-Id: 913651056C X-Migadu-Spam-Score: -3.02 X-Spam-Score: -3.02 X-TUID: Rrh4vyJqCMVi Hello all I'm using the Org agenda to show when certain church occasions will happen. Mostly I've got them working correctly, after "stealing" the method used in holidays.el for finding the date of Easter, along with someone else's function that then uses that to find the difference between Easter and today. (I'm pretty sure that whole idea was on emacswiki, and I think Paul Sexton put it together.) So now I have a much smaller problem to solve, but I don't understand how to get it to work; I suspect it has to do with how dates get formatted within different functions. Using what I already have, I can do this: * Example 1 <%%(= 245 (mf-days-from-easter))> because "mf-days-from-easter" is defined in my init file, along with the definition of Easter itself. This does what it looks like it should do; this year, Example 1 is shown on December 1. And I can do * Example 2 <%%(and (diary-float 1 0 5 7) (<= (mf-days-from-easter) -56))> to say "five Sundays after January 6th, but only if Easter is still 8 weeks away or more". But Example 1 isn't quite finished, because that date is too close to Christmas. I can easily show a diary sexp defining when "too close to Christmas" is: <%%(diary-float 12 0 -4 24)> So I want to combine these ideas, to say "Show Example 1 in the agenda 245 days after Easter each year, but only if it's earlier than the fourth Sunday before Christmas". I could do a long string of (and (not this day, not this day, etc etc [insert long list of days] . . . , but that seems like a last resort. Everything in this question fits into "the current year according to the agenda view" - there's no need to consider dates that cross a year boundary. So: Is there a fairly simple way to define a (mf-days-from-advent) that will do a similar job to what (mf-days-from-easter) is already doing (i.e. it works when used in a diary sexp)? Here are the relevant definitions I've been using: (defun mf-easter (displayed-year) (let* ((century (1+ (/ displayed-year 100))) (shifted-epact ; age of moon for April 5... (% (+ 14 (* 11 (% displayed-year 19)) ; ...by Nicaean rule (- ; ...corrected for the Gregorian century rule (/ (* 3 century) 4)) (/ ; ...corrected for Metonic cycle inaccuracy (+ 5 (* 8 century)) 25) (* 30 century)) ; keeps value positive 30)) (adjusted-epact ; adjust for 29.5 day month (if (or (zerop shifted-epact) (and (= shifted-epact 1) (< 10 (% displayed-year 19)))) (1+ shifted-epact) shifted-epact)) (paschal-moon ; day after the full moon on or after March 21 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year)) adjusted-epact))) (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))) (defun mf-days-from-easter () "When used in a diary sexp, this function will calculate how many days are between the current date (DATE) and Easter Sunday." (- (calendar-absolute-from-gregorian date) (mf-easter (calendar-extract-year date)))) -- David