2007-06-29 19:00A liturgical one-linerIt is not often that the worlds of UNIX skills and liturgical observances intersect. Perhaps that means that any example of something even approaching this is to be highly valued, because of its rarity. That reason alone is almost enough to share an example of what is mentioned in the title to this post. Also, the following story may illustrate the solving of a genuine (albeit slightly esoteric) problem, using the powerful but sometimes daunting toolkit of a UNIX shell and its associated applications. With a toolkit so versatile and modular, it is often the case that parts of the solution to one problem can be used in the solution to another problem, which should make the audience for this post larger than it would otherwise seem. It started with a colleague showing me a little “Easter Egg” (excuse the pun) in the calendar program 15 April 2001 31 March 2002 20 April 2003 11 April 2004 27 March 2005 16 April 2006 8 April 2007 23 March 2008 12 April 2009 4 April 2010 (Again I am resorting to the Perl mode for syntax highlighting my bash command). I was asked what this command or its output represented, and it was not too difficult to infer that these were (the western) dates of Pasch for the first 10 years of this century. The problem arose when I considered this too easy, as it is a feature built into the calendar program. “What about other liturgical dates?” I wondered. In the western calendar, the only ones which move (apart from transference of a minor feast because of coincidence with a more important moveable feast that year) do so in line with Pasch. Thus the feast days for which it is an interesting question to ask what date they are on in a given year, can be found by adding days to the date of Pasch. As an example, I chose to find the date of Pentecost for the year 2010 with a one-liner. As the old saying goes “Well, it is a one-liner, but it depends how long your lines are”. For me the rule is that one does not use semi-colons (to separate what are effectively several consecutive one-liners) or custom scripts. I usually also add the rule of “No backticks”, but I break that rule here. First, the one-liner which I used and its output: ncal -y 2010 -e | sed ’s/^ //’ | sed ’s/ /-/g’ | xargs date +%j -d | sed ’s/.*/60*60*24*(48+&)/’ | bc | xargs echo `date -d 2010-01-01 +%s` + | bc | sed ’s/^/@/’ | xargs date -u +"%F %T %Z" -d
2010-05-23 00:00:00 UTC and now, more verbosely, an explanation of how and why this works:
There are a few things to say about this calculation, apart from just how the individual steps work. For instance, even if Pasch could fall before 03-01 (instead of being limited to between 03-22 and 04-25 inclusive), the calculation would not fall foul of leap years as it does not rely on there being a certain number of days in any month. The other point to mention is due to the use of “48” as the number days to be added after Pasch to reach Pentecost. To explain this, I first have to point out that date +%j gives the number of the day of the year (DoY) on which Pasch falls, with 01-01 being day 1, thus: DoY * 24 * 60 * 60 includes the seconds up until the end of that day of the year. This means one day must be subtracted to get the seconds until the start of that day. Then note that there are 49 days in 7 weeks, and Pentecost is the 50th day after 7 weeks of Pasch (starting on and including the day of Pasch). So the period is 49 days, starting from the beginning of Pasch or 48 days starting from the end of Pasch. Wikipedia says |
QuicksearchCategoriesSyndicate This BlogBlog Administration |
Since my liturgical one-liner 2 years ago, I have not read much discussion of the connections between the worlds of Free software and religion.
Tracked: Aug 09, 23:18