help-gawk
[Top][All Lists]
Advanced

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

Re: How to determine the date of Easter?


From: Neil R. Ormos
Subject: Re: How to determine the date of Easter?
Date: Sun, 22 Aug 2021 12:44:48 -0500 (CDT)

Peng Yu wrote:

> It seems that it is complicated to determine the
> date of Easter. Is there a good awk way to
> compute Easter date? Thanks.
> 
> https://www.timeanddate.com/calendar/determining-easter-date.html

gawk 'BEGIN{c="LC_ALL=C; ncal -e"; if (f=(c | getline d0)) { \
  d1=substr(strftime("%Y"), 1, 2) substr(d0, 7, 2) " " substr(d0, 1, 2) " " 
substr(d0, 4, 2) " 12 00 00"; \
  t=mktime(d1); if (t>1000) print strftime("Easter: %Y-%m-%d", t); else print 
"Error converting ncal result."}; \
  close(c); }'

Anticipating the inevitable complaints: 

(1) The ncal utility is packaged for many xBSD and
    GNU/Linux operating systems.

(2) The source code for ncal is readily available
    and whatever it does could be reused in an awk
    program.

(3) A simple algorithm for determining the date of
    Easter that works for a trivial range of
    years, with other limitations, is displayed on
    the web site of the Greenwich Observatory.



reply via email to

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