all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [RFC] Extend holiday-greek-orthodox-easter in calendar
@ 2015-07-05 21:42 Foivos S. Zakkak
  0 siblings, 0 replies; 2+ messages in thread
From: Foivos S. Zakkak @ 2015-07-05 21:42 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2662 bytes --]


* Description

Extend holiday-greek-orthodox-easter to work like holiday-easter-etc.
That is, accept two optional arguments (n string) and calculate the Date
of Nth day after Easter (named STRING), if visible in calendar window.
The date is calculated according to the rule of the Council of Nicaea.

For backwards compatibility, if this function is called with no
arguments, then it returns the Pascha (Greek Orthodox Easter) day.

* The patch

--8<---------------cut here---------------start------------->8---
--- holidays_orig.el	2015-07-06 00:27:54.992714111 +0300
+++ holidays.el	2015-07-06 00:37:19.530996341 +0300
@@ -791,8 +791,20 @@
 ;; Prior call to calendar-julian-from-absolute will autoload cal-julian.
 (declare-function calendar-julian-to-absolute "cal-julian" (date))

-(defun holiday-greek-orthodox-easter ()
-  "Date of Easter according to the rule of the Council of Nicaea."
+(defun holiday-greek-orthodox-easter (&optional n string)
+  "Date of Nth day after Easter (named STRING), if visible in calendar
+window.  The date is calculated according to the rule of the Council of
+Nicaea.  Negative values of N are interpreted as days before Easter.
+STRING is used purely for display purposes.  The return value has the
+form ((MONTH DAY YEAR) STRING), where the date is that of the Nth day
+before or after Easter.
+
+For backwards compatibility, if this function is called with no
+arguments, then it returns the Pascha (Greek Orthodox Easter)
+day."
+  ;; Backwards compatibility layer.
+  (if (not n)
+      (holiday-greek-orthodox-easter 0 "Pascha (Greek Orthodox Easter)")
   (let* ((m displayed-month)
          (y displayed-year)
          (julian-year (progn
@@ -808,11 +820,11 @@
          (paschal-moon      ; day after full moon on or after March 21
           (- (calendar-julian-to-absolute (list 4 19 julian-year))
              shifted-epact))
-         (nicaean-easter           ; Sunday following the Paschal moon
-          (calendar-gregorian-from-absolute
-           (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))))
-    (if (calendar-date-is-visible-p nicaean-easter)
-        (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))
+         ;; Sunday following the Paschal moon
+         (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
+         (greg (calendar-gregorian-from-absolute (+ abs-easter n))))
+    (if (calendar-date-is-visible-p greg)
+          (list (list greg string))))))

 (provide 'holidays)

--8<---------------cut here---------------end--------------->8---

Kind regards,
Foivos
--
WWW: foivos.zakkak.net
PGP: 7B40 69D9 29BA AE91 C0B3  220A 0846 BFD1 03F0 4EA1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 212 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [RFC] Extend holiday-greek-orthodox-easter in calendar
@ 2015-08-13 13:36 Foivos S. Zakkak
  0 siblings, 0 replies; 2+ messages in thread
From: Foivos S. Zakkak @ 2015-08-13 13:36 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2662 bytes --]


* Description

Extend holiday-greek-orthodox-easter to work like holiday-easter-etc.
That is, accept two optional arguments (n string) and calculate the Date
of Nth day after Easter (named STRING), if visible in calendar window.
The date is calculated according to the rule of the Council of Nicaea.

For backwards compatibility, if this function is called with no
arguments, then it returns the Pascha (Greek Orthodox Easter) day.

* The patch

--8<---------------cut here---------------start------------->8---
--- holidays_orig.el	2015-07-06 00:27:54.992714111 +0300
+++ holidays.el	2015-07-06 00:37:19.530996341 +0300
@@ -791,8 +791,20 @@
 ;; Prior call to calendar-julian-from-absolute will autoload cal-julian.
 (declare-function calendar-julian-to-absolute "cal-julian" (date))

-(defun holiday-greek-orthodox-easter ()
-  "Date of Easter according to the rule of the Council of Nicaea."
+(defun holiday-greek-orthodox-easter (&optional n string)
+  "Date of Nth day after Easter (named STRING), if visible in calendar
+window.  The date is calculated according to the rule of the Council of
+Nicaea.  Negative values of N are interpreted as days before Easter.
+STRING is used purely for display purposes.  The return value has the
+form ((MONTH DAY YEAR) STRING), where the date is that of the Nth day
+before or after Easter.
+
+For backwards compatibility, if this function is called with no
+arguments, then it returns the Pascha (Greek Orthodox Easter)
+day."
+  ;; Backwards compatibility layer.
+  (if (not n)
+      (holiday-greek-orthodox-easter 0 "Pascha (Greek Orthodox Easter)")
   (let* ((m displayed-month)
          (y displayed-year)
          (julian-year (progn
@@ -808,11 +820,11 @@
          (paschal-moon      ; day after full moon on or after March 21
           (- (calendar-julian-to-absolute (list 4 19 julian-year))
              shifted-epact))
-         (nicaean-easter           ; Sunday following the Paschal moon
-          (calendar-gregorian-from-absolute
-           (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))))
-    (if (calendar-date-is-visible-p nicaean-easter)
-        (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))
+         ;; Sunday following the Paschal moon
+         (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
+         (greg (calendar-gregorian-from-absolute (+ abs-easter n))))
+    (if (calendar-date-is-visible-p greg)
+          (list (list greg string))))))

 (provide 'holidays)

--8<---------------cut here---------------end--------------->8---

Kind regards,
Foivos
--
WWW: foivos.zakkak.net
PGP: 7B40 69D9 29BA AE91 C0B3  220A 0846 BFD1 03F0 4EA1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 212 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-13 13:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-05 21:42 [RFC] Extend holiday-greek-orthodox-easter in calendar Foivos S. Zakkak
  -- strict thread matches above, loose matches on Subject: below --
2015-08-13 13:36 Foivos S. Zakkak

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.