The Lectionary class calculates the holy days over a calendar year. Here is some code that demonstrates how to use the object:
<?
$year = intval(strftime("%Y",gmmktime()));
require_once('Lectionary.class');
// This loads the Lectionary.class and makes it available
$lectionary = new Lectionary();
// Returns an associative array containing the key as the date in seconds
// since January 1, 1970 and the value as the day's Lectionary index number.
$l = $lectionary->get_calendar();
// Loop through each date and print it and the day's title and scripture
$page->content .= "<h2> Lectionary for ".$year."</h2>n";
foreach ( $l as $key => $val) {
$page->content .= '<h3>'.$lectionary->get_title($key,$val).' (Year '.$lectionary->get_cycle($key).")</h3>n";
$page->content .= "</p>n";
$page->content .= '<b>Date:</b> '.$lectionary->get_long_date($key)."<br />n";
$page->content .= '<b>Old Testament:</b> <a href="../bible/?verse=' .
urlencode($lectionary->get_scripture($key,$val,'old')) . '">' .
$lectionary->get_scripture($key,$val,'old') . "</a><br />n";
$page->content .= '<b>Psalms:</b> <a href="../bible/?verse=' .
urlencode($lectionary->get_scripture($key,$val,'psalms')) .'">'.
$lectionary->get_scripture($key,$val,'psalms') . "</a><br />n";
$page->content .= '<b>New Testament:</b> <a href="../bible/?verse=' .
urlencode($lectionary->get_scripture($key,$val,'new')) .'">'.
$lectionary->get_scripture($key,$val,'new') . "</a><br />n";
$page->content .= '<b>Gospel:</b> <a href="../bible/?verse=' .
urlencode($lectionary->get_scripture($key,$val,'gospel')) .'">'.
$lectionary->get_scripture($key,$val,'gospel') . "</a><br />n";
$page->content .= "</p>n";
}
?>
Here is how that code looks when it is run:
Lectionary for 2010
2nd Sunday after Christmas Day (Year C)
Date: Sunday, January 03rd, 2010, 11:00Old Testament: Jer. 31:7-14
Psalms: Ps. 147:12-20
New Testament: Eph. 1:3-14
Gospel: John 1:1-18
Epiphany of the Lord (Year C)
Date: Wednesday, January 06th, 2010, 11:00Old Testament: Isa. 60:1-6
Psalms: Ps. 72:1-7,10-14
New Testament: Eph. 3:1-12
Gospel: Matt. 2:1-12
Baptism of the Lord (Year C)
Date: Sunday, January 10th, 2010, 11:00Old Testament: Isa. 43:1-7
Psalms: Ps. 29
New Testament: Acts 8:14-17
Gospel: Luke 3:15-17,21-22
2nd Sunday in Ordinary Time (Year C)
Date: Sunday, January 17th, 2010, 11:00Old Testament: Isa. 62:1-5
Psalms: Ps. 36:5-10
New Testament: 1 Cor. 12:1-11
Gospel: John 2:1-11
3rd Sunday in Ordinary Time (Year C)
Date: Sunday, January 24th, 2010, 11:00Old Testament: Neh. 8:1-3,5-6,8-10
Psalms: Ps. 19
New Testament: 1 Cor. 12:12-31
Gospel: Luke 4:14-21
4th Sunday in Ordinary Time (Year C)
Date: Sunday, January 31st, 2010, 11:00Old Testament: Jer. 1:4-10
Psalms: Ps. 71:1-6
New Testament: 1 Cor. 13:1-13
Gospel: Luke 4:21-30
5th Sunday in Ordinary Time (Year C)
Date: Sunday, February 07th, 2010, 11:00Old Testament: Isa. 6:1-13
Psalms: Ps. 138
New Testament: 1 Cor. 15:1-11
Gospel: Luke 5:1-11
Transfiguration of the Lord (Year C)
Date: Sunday, February 14th, 2010, 11:00Old Testament: Ex. 34:29-35
Psalms: Ps. 99
New Testament: 2 Cor. 3:12-4:2
Gospel: Luke 9:28-43
Ash Wednesday (Year C)
Date: Wednesday, February 17th, 2010, 11:00Old Testament: Isa. 58:1-12
Psalms: Ps. 51:1-17
New Testament: 2 Cor. 5:20-6:10
Gospel: Matt. 6:1-6,16-21
1st Sunday in Lent (Year C)
Date: Sunday, February 21st, 2010, 11:00Old Testament: Deut. 26:1-11
Psalms: Ps. 91:1-2,9-16
New Testament: Rom. 10:8-13
Gospel: Luke 4:1-13
2nd Sunday in Lent (Year C)
Date: Sunday, February 28th, 2010, 11:00Old Testament: Gen. 15:1-12,17-18
Psalms: Ps. 27
New Testament: Philip. 3:17-4:1
Gospel: Luke 13:31-35
3rd Sunday in Lent (Year C)
Date: Sunday, March 07th, 2010, 11:00Old Testament: Isa. 55:1-9
Psalms: Ps. 63:1-8
New Testament: 1 Cor. 10:1-13
Gospel: Luke 13:1-9
4th Sunday in Lent (Year C)
Date: Sunday, March 14th, 2010, 11:00Old Testament: Josh. 5:9-12
Psalms: Ps. 32
New Testament: 2 Cor. 5:16-21
Gospel: Luke 15:1-3,11-32
5th Sunday in Lent (Year C)
Date: Sunday, March 21st, 2010, 11:00Old Testament: Isa. 43:16-21
Psalms: Ps. 126
New Testament: Philip. 3:4-14
Gospel: John 12:1-8
Passion/Palm Sunday (Year C)
Date: Sunday, March 28th, 2010, 11:00Old Testament: Isa. 50:4-9
Psalms: Ps. 118:1-2,19-29
New Testament: Philip. 2:5-11
Gospel: Luke 19:28-40
Monday of Holy Week (Year C)
Date: Monday, March 29th, 2010, 11:00Old Testament: Isa. 42:1-9
Psalms: Ps. 36:5-11
New Testament: Heb. 9:11-15
Gospel: John 12:1-11
Tuesday of Holy Week (Year C)
Date: Tuesday, March 30th, 2010, 11:00Old Testament: Isa. 49:1-7
Psalms: Ps. 71:1-14
New Testament: 1 Cor. 1:18-31
Gospel: John 12:20-36
Wednesday of Holy Week (Year C)
Date: Wednesday, March 31st, 2010, 11:00Old Testament: Isa. 50:4-9
Psalms: Ps. 70
New Testament: Heb. 12:1-3
Gospel: John 13:21-32
Maundy Thursday (Year C)
Date: Thursday, April 01st, 2010, 11:00Old Testament: Ex. 12:1-14
Psalms: Ps. 116:1-2,12-19
New Testament: 1 Cor. 11:23-26
Gospel: John 13:1-17,31-35
Good Friday (Year C)
Date: Friday, April 02nd, 2010, 11:00Old Testament: Isa. 52:13-53:12
Psalms: Ps. 22
New Testament: Heb. 10:16-25
Gospel: John 18:1-19:42
Easter Vigil (Year C)
Date: Saturday, April 03rd, 2010, 11:00Old Testament: Ex. 14:10-31; 15:20-21
Psalms: Ps. 46
New Testament: Rom. 6:3-11
Gospel: Luke 24:1-12
Resurrection of the Lord (Year C)
Date: Sunday, April 04th, 2010, 11:00Old Testament: Isa. 65:17-25
Psalms: Ps. 118:1-2,14-24
New Testament: 1 Cor. 15:19-26
Gospel: John 20:1-18
Easter Evening (Year C)
Date: Sunday, April 04th, 2010, 19:00Old Testament: Isa. 25:6-9
Psalms: Ps. 114
New Testament: 1 Cor. 5:6-8
Gospel: Luke 24:13-49
2nd Sunday of Easter (Year C)
Date: Sunday, April 11th, 2010, 11:00Old Testament: Acts 5:27-32
Psalms: Ps. 150
New Testament: Rev. 1:4-8
Gospel: John 20:19-31
3rd Sunday of Easter (Year C)
Date: Sunday, April 18th, 2010, 11:00Old Testament: Acts 9:1-20
Psalms: Ps. 30
New Testament: Rev. 5:11-14
Gospel: John 21:1-19
4th Sunday of Easter (Year C)
Date: Sunday, April 25th, 2010, 11:00Old Testament: Acts 9:36-43
Psalms: Ps. 23
New Testament: Rev. 7:9-17
Gospel: John 10:22-30
5th Sunday of Easter (Year C)
Date: Sunday, May 02nd, 2010, 11:00Old Testament: Acts 11:1-18
Psalms: Ps. 148
New Testament: Rev. 21:1-6
Gospel: John 13:31-35
6th Sunday of Easter (Year C)
Date: Sunday, May 09th, 2010, 11:00Old Testament: Acts 16:9-15
Psalms: Ps. 67
New Testament: Rev. 21:10,21:22-22:5
Gospel: John 14:23-29
Ascension of the Lord (Year C)
Date: Thursday, May 13th, 2010, 11:00Old Testament: Acts 1:1-11
Psalms: Ps. 47
New Testament: Eph. 1:15-23
Gospel: Luke 24:44-53
7th Sunday of Easter (Year C)
Date: Sunday, May 16th, 2010, 11:00Old Testament: Acts 16:16-34
Psalms: Ps. 97
New Testament: Rev. 22:12-14,16-17,20-21
Gospel: John 17:20-26
Day of Pentecost (Year C)
Date: Sunday, May 23rd, 2010, 11:00Old Testament: Gen. 11:1-9
Psalms: Ps. 104:24-34,35
New Testament: Rom. 8:14-17
Gospel: John 14:8-17,25-27
Trinity Sunday (Year C)
Date: Sunday, May 30th, 2010, 11:00Old Testament: Prov. 8:1-4,22-31
Psalms: Ps. 8
New Testament: Rom. 5:1-5
Gospel: John 16:12-15
10th Sunday in Ordinary Time (Year C)
Date: Sunday, June 06th, 2010, 11:00Old Testament: 1 Kings 17:8-24
Psalms: Ps. 146
New Testament: Gal. 1:11-24
Gospel: Luke 7:11-17
11th Sunday in Ordinary Time (Year C)
Date: Sunday, June 13th, 2010, 11:00Old Testament: 1 Kings 21:1-21
Psalms: Ps. 5:1-8
New Testament: Gal. 2:15-21
Gospel: Luke 7:36-8:3
12th Sunday in Ordinary Time (Year C)
Date: Sunday, June 20th, 2010, 11:00Old Testament: 1 Kings 19:1-15
Psalms: Ps. 42-43
New Testament: Gal. 3:23-29
Gospel: Luke 8:26-39
13th Sunday in Ordinary Time (Year C)
Date: Sunday, June 27th, 2010, 11:00Old Testament: 2 Kings 2:1-2,6-14
Psalms: Ps. 77:1-2,11-20
New Testament: Gal. 5:1,13-25
Gospel: Luke 9:51-62
14th Sunday in Ordinary Time (Year C)
Date: Sunday, July 04th, 2010, 11:00Old Testament: 2 Kings 5:1-14
Psalms: Ps. 30
New Testament: Gal. 6:1-16
Gospel: Luke 10:1-11,16-20
15th Sunday in Ordinary Time (Year C)
Date: Sunday, July 11th, 2010, 11:00Old Testament: Amos 7:7-17
Psalms: Ps. 82
New Testament: Col. 1:1-14
Gospel: Luke 10:25-37
16th Sunday in Ordinary Time (Year C)
Date: Sunday, July 18th, 2010, 11:00Old Testament: Amos 8:1-12
Psalms: Ps. 52
New Testament: Col. 1:15-28
Gospel: Luke 10:38-42
17th Sunday in Ordinary Time (Year C)
Date: Sunday, July 25th, 2010, 11:00Old Testament: Hos. 1:2-10
Psalms: Ps. 85
New Testament: Col. 2:6-19
Gospel: Luke 11:1-13
18th Sunday in Ordinary Time (Year C)
Date: Sunday, August 01st, 2010, 11:00Old Testament: Hos. 11:1-11
Psalms: Ps. 107:1-9,43
New Testament: Col. 3:1-11
Gospel: Luke 12:13-21
19th Sunday in Ordinary Time (Year C)
Date: Sunday, August 08th, 2010, 11:00Old Testament: Isa. 1:1,10-20
Psalms: Ps. 50:1-8,22-23
New Testament: Heb. 11:1-3,8-16
Gospel: Luke 12:32-40
20th Sunday in Ordinary Time (Year C)
Date: Sunday, August 15th, 2010, 11:00Old Testament: Isa. 5:1-7
Psalms: Ps. 80:1-2,8-19
New Testament: Heb. 11:29-12:2
Gospel: Luke 12:49-56
21st Sunday in Ordinary Time (Year C)
Date: Sunday, August 22nd, 2010, 11:00Old Testament: Jer. 1:4-10
Psalms: Ps. 71:1-6
New Testament: Heb. 12:18-29
Gospel: Luke 13:10-17
22nd Sunday in Ordinary Time (Year C)
Date: Sunday, August 29th, 2010, 11:00Old Testament: Jer. 2:4-13
Psalms: Ps. 81:1,10-16
New Testament: Heb. 13:1-8,15-16
Gospel: Luke 14:1,7-14
23rd Sunday in Ordinary Time (Year C)
Date: Sunday, September 05th, 2010, 11:00Old Testament: Jer. 18:1-11
Psalms: Ps. 139:1-6,13-18
New Testament: Philemon 1:1-21
Gospel: Luke 14:25-33
24th Sunday in Ordinary Time (Year C)
Date: Sunday, September 12th, 2010, 11:00Old Testament: Jer. 4:11-12,22-28
Psalms: Ps. 14
New Testament: 1 Tim. 1:12-17
Gospel: Luke 15:1-10
25th Sunday in Ordinary Time (Year C)
Date: Sunday, September 19th, 2010, 11:00Old Testament: Jer. 8:18-9:1
Psalms: Ps. 79:1-9
New Testament: 1 Tim. 2:1-7
Gospel: Luke 16:1-13
26th Sunday in Ordinary Time (Year C)
Date: Sunday, September 26th, 2010, 11:00Old Testament: Jer. 32:1-3,6-15
Psalms: Ps. 91:1-6,14-16
New Testament: 1 Tim. 6:6-19
Gospel: Luke 16:19-31
27th Sunday in Ordinary Time (Year C)
Date: Sunday, October 03rd, 2010, 11:00Old Testament: Lam. 1:1-6
Psalms: Ps. 137
New Testament: 2 Tim. 1:1-14
Gospel: Luke 17:5-10
28th Sunday in Ordinary Time (Year C)
Date: Sunday, October 10th, 2010, 11:00Old Testament: Jer. 29:1,4-7
Psalms: Ps. 66:1-12
New Testament: 2 Tim. 2:8-15
Gospel: Luke 17:11-19
29th Sunday in Ordinary Time (Year C)
Date: Sunday, October 17th, 2010, 11:00Old Testament: Jer. 31:27-34
Psalms: Ps. 119:97-104
New Testament: 2 Tim. 3:14-4:5
Gospel: Luke 18:1-8
30th Sunday in Ordinary Time (Year C)
Date: Sunday, October 24th, 2010, 11:00Old Testament: Joel 2:23-32
Psalms: Ps. 65
New Testament: 2 Tim. 4:6-8,16-18
Gospel: Luke 18:9-14
31st Sunday in Ordinary Time (Year C)
Date: Sunday, October 31st, 2010, 11:00Old Testament: Hab. 1:1-4; 2:1-4
Psalms: Ps. 119:137-144
New Testament: 2 Thess. 1:1-4,11-12
Gospel: Luke 19:1-10
All Saints' Day (Year C)
Date: Monday, November 01st, 2010, 08:00Old Testament: Dan. 7:1-3,15-18
Psalms: Ps. 149
New Testament: Eph. 1:11-23
Gospel: Luke 6:20-31
32nd Sunday in Ordinary Time (Year C)
Date: Sunday, November 07th, 2010, 11:00Old Testament: Hag. 1:15-2:9
Psalms: Ps. 98
New Testament: 2 Thess. 2:1-5,13-17
Gospel: Luke 20:27-38
33rd Sunday in Ordinary Time (Year C)
Date: Sunday, November 14th, 2010, 11:00Old Testament: Isa. 65:17-25
Psalms: Isa. 12
New Testament: 2 Thess. 3:6-13
Gospel: Luke 21:5-19
Christ the King (Year C)
Date: Sunday, November 21st, 2010, 11:00Old Testament: Jer. 23:1-6
Psalms: Luke 1:68-79
New Testament: Col. 1:11-20
Gospel: Luke 23:33-43
1st Sunday of Advent (Year A)
Date: Sunday, November 28th, 2010, 11:00Old Testament: Isa. 2:1-5
Psalms: Ps. 122
New Testament: Rom. 13:11-14
Gospel: Matt. 24:36-44
2nd Sunday of Advent (Year A)
Date: Sunday, December 05th, 2010, 11:00Old Testament: Isa. 11:1-10
Psalms: Ps. 72:1-7,18-19
New Testament: Rom. 15:4-13
Gospel: Matt. 3:1-12
3rd Sunday of Advent (Year A)
Date: Sunday, December 12th, 2010, 11:00Old Testament: Isa. 35:1-10
Psalms: Ps. 146:5-10
New Testament: James 5:7-10
Gospel: Matt. 11:2-11
4th Sunday of Advent (Year A)
Date: Sunday, December 19th, 2010, 11:00Old Testament: Isa. 7:10-16
Psalms: Ps. 80:1-7,17-19
New Testament: Rom. 1:1-7
Gospel: Matt. 1:18-25
Christmas Eve (Year A)
Date: Friday, December 24th, 2010, 21:00Old Testament: Isa. 9:2-7
Psalms: Ps. 96
New Testament: Titus 2:11-14
Gospel: Luke 2:1-20
Christmas Day - Dawn (Year A)
Date: Saturday, December 25th, 2010, 08:00Old Testament: Isa. 62:6-12
Psalms: Ps. 97
New Testament: Titus 3:4-7
Gospel: Luke 2:1-20
Christmas Day (Year A)
Date: Saturday, December 25th, 2010, 11:00Old Testament: Isa. 52:7-10
Psalms: Ps. 98
New Testament: Heb. 1:1-12
Gospel: John 1:1-14
1st Sunday after Christmas Day (Year A)
Date: Sunday, December 26th, 2010, 11:00Old Testament: Isa. 63:7-9
Psalms: Ps. 148
New Testament: Heb. 2:10-18
Gospel: Matt. 2:13-23
Here is the Lectionary object source code. It may run out to the right a bit.
<?
/*
##################################################
#
# Filename..........: $RCSfile: Lectionary.class,v $
# Original Author...: Anthony L. Awtrey
# Version...........: $Revision: 0.1 $
# Last Modified By..: $Author: aawtrey $
# Last Modified.....: $Date: 2006/09/21 18:15:56 $
#
# Copyright 2006 Anthony Awtrey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
*/
/*
* This class uses date calculations to generate the lectionary dates for a
* given year.
*/
class Lectionary {
var $year;
var $cycle;
var $calendar;
var $lectionary;
/*
* Class initialization
*/
function Lectionary($year='') {
global $_SERVER;
global $_SESSION;
global $_REQUEST;
global $_POST;
global $_GET;
$this->set_year($year);
}
/*
* Sets the year or the current year if nothing is passed
*/
function set_year($year='') {
if ( $year == '' ) {
$this->year = gmstrftime("%Y", gmmktime());
} else {
$this->year = $year;
}
$this->load_lectionary();
$this->generate_calendar();
}
/*
* Returns the year
*/
function get_year() {
return($this->year);
}
function load_lectionary() {
if ( is_file(constant("RELPATH").'include/lectionary.xml') ) {
$this->lectionary = simplexml_load_file(constant("RELPATH").'include/lectionary.xml');
return(true);
} else {
$this->lectionary = false;
return(false);
}
}
function get_cycle($unixdate) {
$y = array('A','B','C','A');
$year = gmstrftime("%Y", $unixdate);
$mod = ( ($year-1) % 3 );
if ( $unixdate < $this->get_advent_sunday() )
{
return($y[$mod]);
} else {
return($y[$mod+1]);
}
}
/*
* Get the name for a given number
*/
function get_number_name($number) {
$name = array(
1 => 'First',
2 => 'Second',
3 => 'Third',
4 => 'Fourth',
5 => 'Fifth',
6 => 'Sixth',
7 => 'Seventh'
);
return isset($name[$number]) ? $name[$number] : '';
}
/*
* Get the english suffix for a given number
*/
function get_suffix($dayOfTheMonth) {
$suffix = array(
1 => 'st',
2 => 'nd',
3 => 'rd',
21 => 'st',
22 => 'nd',
23 => 'rd',
31 => 'st'
);
return isset($suffix[$dayOfTheMonth]) ? $suffix[$dayOfTheMonth] : 'th';
}
/*
* Get the long format date for a given unix timestamp
*/
function get_long_date($timestamp) {
$s = $this->get_suffix(intval(gmstrftime("%d",$timestamp)));
return gmstrftime("%A, %B %d<sup>$s</sup>, %Y, %H:%M", $timestamp );
//return gmstrftime("%A, %B %d$s, %Y", $timestamp );
}
/*
* Get the timestamp for the first sunday of the year
*/
function get_first_sunday() {
$dow = intval(gmstrftime("%w", gmmktime(11,0,0,1,1,$this->year)));
if ( $dow == 0 ) { $dow = 7; }
$delta = 7 - $dow;
return intval(gmmktime(11,0,0,1,1+$delta,$this->year));
}
/*
* Get the timestamp for the first sunday after Epiphany (Jan 6)
*/
function get_sunday_after_epiphany() {
$dow = intval(gmstrftime("%w", gmmktime(11,0,0,1,6,$this->year)));
if ( $dow == 0 ) {
$delta = 7;
} else {
$delta = 7 - $dow;
}
return intval(gmmktime(11,0,0,1,6+$delta,$this->year));
}
/*
* Get the timestamp for easter in a given year
*/
function getEasterSunday() {
return intval(gmmktime(11,0,0,3,21+easter_days($this->year),$this->year));
}
/*
* Get the timestamp for the first Sunday in advent
*/
function get_advent_sunday() {
$dow = intval(gmstrftime("%w", gmmktime(11,0,0,12,25,$this->year)));
if ( $dow == 0 ) { $dow = 7; }
$delta = -28 + ( 7 - $dow );
return intval(gmmktime(11,0,0,12,25+$delta,$this->year));
}
/*
* Calculate all the calendar dates
*/
function generate_calendar() {
$day = 86400; # Number of seconds in a day
##
## These are the fixed days in the year
##
if ( $this->get_first_sunday() == gmmktime(11,0,0,1,1,$this->year) ) {
$this->calendar[$this->get_first_sunday()] = '8'; # First Sunday after Christmas Day
} else {
$this->calendar[$this->get_first_sunday()] = '9'; # Second Sunday after Christmas Day
}
$this->calendar[gmmktime(11, 0, 0, 1, 6, $this->year)] = '10'; # Epiphany of the Lord
$this->calendar[$this->get_sunday_after_epiphany()] = '11'; # Baptism of the Lord
$this->calendar[$this->getEasterSunday()-(49*$day)] = '12'; # Transfiguration Sunday
$this->calendar[$this->getEasterSunday()-(46*$day)] = '13'; # Ash Wednesday
$this->calendar[$this->getEasterSunday()-(42*$day)] = '14'; # First Sunday in Lent
$this->calendar[$this->getEasterSunday()-(35*$day)] = '15'; # Second Sunday in Lent
$this->calendar[$this->getEasterSunday()-(28*$day)] = '16'; # Third Sunday in Lent
$this->calendar[$this->getEasterSunday()-(21*$day)] = '17'; # Fourth Sunday in Lent
$this->calendar[$this->getEasterSunday()-(14*$day)] = '18'; # Fifth Sunday in Lent
$this->calendar[$this->getEasterSunday()-(7*$day)] = '19'; # Palm/Passion Sunday
$this->calendar[$this->getEasterSunday()-(6*$day)] = '20'; # Monday of Holy Week
$this->calendar[$this->getEasterSunday()-(5*$day)] = '21'; # Tuesday of Holy Week
$this->calendar[$this->getEasterSunday()-(4*$day)] = '22'; # Wednesday of Holy Week
$this->calendar[$this->getEasterSunday()-(3*$day)] = '23'; # Maundy Thursday
$this->calendar[$this->getEasterSunday()-(2*$day)] = '24'; # Good Friday
$this->calendar[$this->getEasterSunday()-(1*$day)] = '25'; # Holy Saturday
$this->calendar[$this->getEasterSunday()] = '26'; # Easter Sunday
$this->calendar[$this->getEasterSunday()+(8*60*60)] = '27'; # Easter Evening
$this->calendar[$this->getEasterSunday()+(7*$day)] = '28'; # Second Sunday of Easter
$this->calendar[$this->getEasterSunday()+(14*$day)] = '29'; # Third Sunday of Easter
$this->calendar[$this->getEasterSunday()+(21*$day)] = '30'; # Fourth Sunday of Easter
$this->calendar[$this->getEasterSunday()+(28*$day)] = '31'; # Fifth Sunday of Easter
$this->calendar[$this->getEasterSunday()+(35*$day)] = '32'; # Sixth Sunday of Easter
$this->calendar[$this->getEasterSunday()+(39*$day)] = '33'; # Ascension Sunday
$this->calendar[$this->getEasterSunday()+(42*$day)] = '34'; # Seventh Sunday of Easter
$this->calendar[$this->getEasterSunday()+(49*$day)] = '35'; # Day of Pentecost
$this->calendar[$this->getEasterSunday()+(56*$day)] = '36'; # Trinity Sunday
$this->calendar[gmmktime(8, 0, 0, 11, 1, $this->year)] = '37'; # All Saint's Day
$this->calendar[$this->get_advent_sunday()-(7*$day)] = '38'; # Christ the King Sunday
$this->calendar[$this->get_advent_sunday()] = '1'; # First Sunday in Advent
$this->calendar[$this->get_advent_sunday()+(7*$day)] = '2'; # Second Sunday in Advent
$this->calendar[$this->get_advent_sunday()+(14*$day)] = '3'; # Third Sunday in Advent
$this->calendar[$this->get_advent_sunday()+(21*$day)] = '4'; # Fourth Sunday in Advent
$this->calendar[gmmktime(21, 0, 0, 12, 24, $this->year)] = '5'; # Christmas Eve
$this->calendar[gmmktime(8, 0, 0, 12, 25, $this->year)] = '6'; # Christmas Day (Sunrise)
$this->calendar[gmmktime(11, 0, 0, 12, 25, $this->year)] = '7'; # Christmas Day
if ( 0 != intval(gmstrftime("%w", gmmktime(11,0,0,12,25,$this->year))) ) {
$this->calendar[$this->get_advent_sunday()+(28*$day)] = '8'; # First Sunday after Christmas Day
}
##
## These are the variable days in the year
##
# Variable Sundays after Epiphany counting forward from 2nd Sunday in Ordinary Time
$index=39;
for ( $i=$this->get_sunday_after_epiphany()+(7*$day); $i<$this->getEasterSunday()-(49*$day); $i=$i+(7*$day) ) {
if ( $this->calendar[$i] == '' ) {
$this->calendar[$i] = $index; # Sunday's after Epiphany
$index++;
}
}
# Variable Sundays after Pentecost counting backwards from 33rd sunday in Ordinary Time
$index=70;
for ( $i=$this->get_advent_sunday()-(14*$day); $i>$this->getEasterSunday()+(56*$day); $i=$i-(7*$day) ) {
if ( $this->calendar[$i] == '' ) {
$this->calendar[$i] = $index; # Sunday's after Pentecost
$index--;
}
}
ksort($this->calendar);
}
/*
* Get the calendar array
*/
function get_calendar()
{
return($this->calendar);
}
function get_calendar_day($unixdate)
{
$year = gmstrftime('%Y',$unixdate);
$month = gmstrftime('%m',$unixdate);
$day = gmstrftime('%d',$unixdate);
$day_start = gmmktime(0,0,0,$month,$day,$year);
$day_end = gmmktime(23,59,59,$month,$day,$year);
$result = array();
foreach ( $this->calendar as $key => $val) {
if ( $key >= $day_start && $key <= $day_end ) {
$result[$key] = $val;
}
}
return($result);
}
function get_title($unixdate,$index) {
$result = '';
$xpath = "//lectionary/year[@name='".$this->get_cycle($unixdate)."']/day[@name='".$index."']/title";
foreach ( $this->lectionary->xpath($xpath) as $text) {
$result .= "$text";
}
return($result);
}
function get_scripture($unixdate,$index,$lesson) {
$result = '';
$xpath = "//lectionary/year[@name='".$this->get_cycle($unixdate)."']/day[@name='".$index."']/scripture/$lesson";
foreach ( $this->lectionary->xpath($xpath) as $text) {
$result .= "$text";
}
return($result);
}
}
?>