The Lectionary class calculates the holy days over a calendar year. Here is some code that demonstrates how to use the object:
<?php
$year = gmdate("Y", gmmktime(NULL));
if ( $_GET['year'] ) {
$year = $_GET['year'];
}
require_once('Lectionary.php');
// This loads the Lectionary.php 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 2024
Epiphany of the Lord (Year B)
Date: Saturday, January 06th, 2024, 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 B)
Date: Sunday, January 07th, 2024, 11:00Old Testament: Gen. 1:1-5
Psalms: Ps. 29
New Testament: Acts 19:1-7
Gospel: Mark 1:4-11
2nd Sunday in Ordinary Time (Year B)
Date: Sunday, January 14th, 2024, 11:00Old Testament: 1 Sam. 3:1-20
Psalms: Ps. 139:1-6,13-18
New Testament: 1 Cor. 6:12-20
Gospel: John 1:43-51
3rd Sunday in Ordinary Time (Year B)
Date: Sunday, January 21st, 2024, 11:00Old Testament: Jonah 3:1-5,10
Psalms: Ps. 62:5-12
New Testament: 1 Cor. 7:29-31
Gospel: Mark 1:14-20
4th Sunday in Ordinary Time (Year B)
Date: Sunday, January 28th, 2024, 11:00Old Testament: Deut. 18:15-20
Psalms: Ps. 111
New Testament: 1 Cor. 8:1-13
Gospel: Mark 1:21-28
5th Sunday in Ordinary Time (Year B)
Date: Sunday, February 04th, 2024, 11:00Old Testament: Isa. 40:21-31
Psalms: Ps. 147:1-11,20
New Testament: 1 Cor. 9:16-23
Gospel: Mark 1:29-39
Transfiguration of the Lord (Year B)
Date: Sunday, February 11th, 2024, 11:00Old Testament: 2 Kings 2:1-12
Psalms: Ps. 50:1-6
New Testament: 2 Cor. 4:3-6
Gospel: Mark 9:2-9
Ash Wednesday (Year B)
Date: Wednesday, February 14th, 2024, 11:00Old Testament: Joel 2:1-2,12-17
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 B)
Date: Sunday, February 18th, 2024, 11:00Old Testament: Gen. 9:8-17
Psalms: Ps. 25:1-10
New Testament: 1 Peter 3:18-22
Gospel: Mark 1:9-15
2nd Sunday in Lent (Year B)
Date: Sunday, February 25th, 2024, 11:00Old Testament: Gen. 17:1-7,15-16
Psalms: Ps. 22:23-31
New Testament: Rom. 4:13-25
Gospel: Mark 8:31-38
3rd Sunday in Lent (Year B)
Date: Sunday, March 03rd, 2024, 11:00Old Testament: Ex. 20:1-17
Psalms: Ps. 19
New Testament: 1 Cor. 1:18-25
Gospel: John 2:13-22
4th Sunday in Lent (Year B)
Date: Sunday, March 10th, 2024, 11:00Old Testament: Num. 21:4-9
Psalms: Ps. 107:1-3,17-22
New Testament: Eph. 2:1-10
Gospel: John 3:14-21
5th Sunday in Lent (Year B)
Date: Sunday, March 17th, 2024, 11:00Old Testament: Jer. 31:31-34
Psalms: Ps. 119:9-16
New Testament: Heb. 5:5-10
Gospel: John 12:20-33
Passion/Palm Sunday (Year B)
Date: Sunday, March 24th, 2024, 11:00Old Testament: Isa. 50:4-9
Psalms: Ps. 31:9-16
New Testament: Philip. 2:5-11
Gospel: Mark 14:1-15:47
Monday of Holy Week (Year B)
Date: Monday, March 25th, 2024, 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 B)
Date: Tuesday, March 26th, 2024, 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 B)
Date: Wednesday, March 27th, 2024, 11:00Old Testament: Isa. 50:4-9
Psalms: Ps. 70
New Testament: Heb. 12:1-3
Gospel: John 13:21-32
Maundy Thursday (Year B)
Date: Thursday, March 28th, 2024, 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 B)
Date: Friday, March 29th, 2024, 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 B)
Date: Saturday, March 30th, 2024, 11:00Old Testament: Ex. 14:10-31; 15:20-21
Psalms: Ex. 15:1-13,17-18
New Testament: Rom. 6:3-11
Gospel: Mark 16:1-8
Resurrection of the Lord (Year B)
Date: Sunday, March 31st, 2024, 11:00Old Testament: Acts 10:34-43
Psalms: Ps. 118:1-2,14-24
New Testament: 1 Cor. 15:1-11
Gospel: Mark 16:1-8
Easter Evening (Year B)
Date: Sunday, March 31st, 2024, 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 B)
Date: Sunday, April 07th, 2024, 11:00Old Testament: Acts 4:32-35
Psalms: Ps. 133
New Testament: 1 John 1:1-2:2
Gospel: John 20:19-31
3rd Sunday of Easter (Year B)
Date: Sunday, April 14th, 2024, 11:00Old Testament: Acts 3:12-19
Psalms: Ps. 4
New Testament: 1 John 3:1-7
Gospel: Luke 24:36-48
4th Sunday of Easter (Year B)
Date: Sunday, April 21st, 2024, 11:00Old Testament: Acts 4:5-12
Psalms: Ps. 23
New Testament: 1 John 3:16-24
Gospel: John 10:11-18
5th Sunday of Easter (Year B)
Date: Sunday, April 28th, 2024, 11:00Old Testament: Acts 8:26-40
Psalms: Ps. 22:25-31
New Testament: 1 John 4:7-21
Gospel: John 15:1-8
6th Sunday of Easter (Year B)
Date: Sunday, May 05th, 2024, 11:00Old Testament: Acts 10:44-48
Psalms: Ps. 98
New Testament: 1 John 5:1-6
Gospel: John 15:9-17
Ascension of the Lord (Year B)
Date: Thursday, May 09th, 2024, 11:00Old Testament: Acts 1:1-11
Psalms: Ps. 93
New Testament: Eph. 1:15-23
Gospel: Luke 24:44-53
7th Sunday of Easter (Year B)
Date: Sunday, May 12th, 2024, 11:00Old Testament: Acts 1:15-17,21-26
Psalms: Ps. 1
New Testament: 1 John 5:9-13
Gospel: John 17:6-19
Day of Pentecost (Year B)
Date: Sunday, May 19th, 2024, 11:00Old Testament: Acts 2:1-21
Psalms: Ps. 104:24-34,35
New Testament: Acts 2:1-21
Gospel: John 15:26-27;16:4-15
Trinity Sunday (Year B)
Date: Sunday, May 26th, 2024, 11:00Old Testament: Isa. 6:1-8
Psalms: Ps. 29
New Testament: Rom. 8:12-17
Gospel: John 3:1-17
9th Sunday in Ordinary Time (Year B)
Date: Sunday, June 02nd, 2024, 11:00Old Testament: 1 Sam. 3:1-20
Psalms: Ps. 139:1-6,13-18
New Testament: 2 Cor. 4:5-12
Gospel: Mark 2:23-3:6
10th Sunday in Ordinary Time (Year B)
Date: Sunday, June 09th, 2024, 11:00Old Testament: 1 Sam. 8:4-20;11:14-15
Psalms: Ps. 138
New Testament: 2 Cor. 4:13-5:1
Gospel: Mark 3:20-35
11th Sunday in Ordinary Time (Year B)
Date: Sunday, June 16th, 2024, 11:00Old Testament: 1 Sam. 15:34-16:13
Psalms: Ps. 20
New Testament: 2 Cor. 5:6-17
Gospel: Mark 4:26-34
12th Sunday in Ordinary Time (Year B)
Date: Sunday, June 23rd, 2024, 11:00Old Testament: 1 Sam. 17:1,4-11,19-23,32-49
Psalms: Ps. 9:9-20
New Testament: 2 Cor. 6:1-13
Gospel: Mark 4:35-41
13th Sunday in Ordinary Time (Year B)
Date: Sunday, June 30th, 2024, 11:00Old Testament: 2 Sam. 1:1,17-27
Psalms: Ps. 130
New Testament: 2 Cor. 8:7-15
Gospel: Mark 5:21-43
14th Sunday in Ordinary Time (Year B)
Date: Sunday, July 07th, 2024, 11:00Old Testament: 2 Sam. 5:1-5,9-10
Psalms: Ps. 48
New Testament: 2 Cor. 12:2-10
Gospel: Mark 6:1-13
15th Sunday in Ordinary Time (Year B)
Date: Sunday, July 14th, 2024, 11:00Old Testament: 2 Sam. 6:1-5,12-19
Psalms: Ps. 24
New Testament: Eph. 1:3-14
Gospel: Mark 6:14-29
16th Sunday in Ordinary Time (Year B)
Date: Sunday, July 21st, 2024, 11:00Old Testament: 2 Sam. 7:1-14
Psalms: Ps. 89:20-37
New Testament: Eph. 2:11-22
Gospel: Mark 6:30-34,53-56
17th Sunday in Ordinary Time (Year B)
Date: Sunday, July 28th, 2024, 11:00Old Testament: 2 Sam. 11:1-15
Psalms: Ps. 14
New Testament: Eph. 3:14-21
Gospel: John 6:1-21
18th Sunday in Ordinary Time (Year B)
Date: Sunday, August 04th, 2024, 11:00Old Testament: 2 Sam. 11:26-12:13
Psalms: Ps. 51:1-12
New Testament: Eph. 4:1-16
Gospel: John 6:24-35
19th Sunday in Ordinary Time (Year B)
Date: Sunday, August 11th, 2024, 11:00Old Testament: 2 Sam. 18:5-9,15,31-33
Psalms: Ps. 130
New Testament: Eph. 4:25-5:2
Gospel: John 6:35,41-51
20th Sunday in Ordinary Time (Year B)
Date: Sunday, August 18th, 2024, 11:00Old Testament: 1 Kings 2:10-12;3:3-14
Psalms: Ps. 111
New Testament: Eph. 5:15-20
Gospel: John 6:51-58
21st Sunday in Ordinary Time (Year B)
Date: Sunday, August 25th, 2024, 11:00Old Testament: 1 Kings 8:1,6,10-11,22-30,41-43
Psalms: Ps. 84
New Testament: Eph. 6:10-20
Gospel: John 6:56-69
22nd Sunday in Ordinary Time (Year B)
Date: Sunday, September 01st, 2024, 11:00Old Testament: Song 2:8-13
Psalms: Ps. 45:1-2,6-9
New Testament: James 1:17-27
Gospel: Mark 7:1-8,14-15,21-23
23rd Sunday in Ordinary Time (Year B)
Date: Sunday, September 08th, 2024, 11:00Old Testament: Prov. 22:1-2,8-9,22-23
Psalms: Ps. 125
New Testament: James 2:1-17
Gospel: Mark 7:24-37
24th Sunday in Ordinary Time (Year B)
Date: Sunday, September 15th, 2024, 11:00Old Testament: Prov. 1:20-33
Psalms: Ps. 19
New Testament: James 3:1-12
Gospel: Mark 8:27-38
25th Sunday in Ordinary Time (Year B)
Date: Sunday, September 22nd, 2024, 11:00Old Testament: Prov. 31:10-31
Psalms: Ps. 1
New Testament: James 3:13-4:3,7-8
Gospel: Mark 9:30-37
26th Sunday in Ordinary Time (Year B)
Date: Sunday, September 29th, 2024, 11:00Old Testament: Esth. 7:1-6,9-10;9:20-22
Psalms: Ps. 124
New Testament: James 5:13-20
Gospel: Mark 9:38-50
27th Sunday in Ordinary Time (Year B)
Date: Sunday, October 06th, 2024, 11:00Old Testament: Job 1:1; 2:1-10
Psalms: Ps. 26
New Testament: Heb. 1:1-4; 2:5-12
Gospel: Mark 10:2-16
28th Sunday in Ordinary Time (Year B)
Date: Sunday, October 13th, 2024, 11:00Old Testament: Job 23:1-9,16-17
Psalms: Ps. 22:1-15
New Testament: Heb. 4:12-16
Gospel: Mark 10:17-31
29th Sunday in Ordinary Time (Year B)
Date: Sunday, October 20th, 2024, 11:00Old Testament: Job 38:1-7,34-41
Psalms: Ps. 104:1-9,24,35
New Testament: Heb. 5:1-10
Gospel: Mark 10:35-45
30th Sunday in Ordinary Time (Year B)
Date: Sunday, October 27th, 2024, 11:00Old Testament: Job 42:1-6,10-17
Psalms: Ps. 34:1-8,19-22
New Testament: Heb. 7:23-28
Gospel: Mark 10:46-52
All Saints' Day (Year B)
Date: Friday, November 01st, 2024, 08:00Old Testament: Isa. 25:6-9
Psalms: Ps. 24
New Testament: Rev. 21:1-6
Gospel: John 11:32-44
31st Sunday in Ordinary Time (Year B)
Date: Sunday, November 03rd, 2024, 11:00Old Testament: Ruth 1:1-18
Psalms: Ps. 146
New Testament: Heb. 9:11-14
Gospel: Mark 12:28-34
32nd Sunday in Ordinary Time (Year B)
Date: Sunday, November 10th, 2024, 11:00Old Testament: Ruth 3:1-5; 4:13-17
Psalms: Ps. 127
New Testament: Heb. 9:24-28
Gospel: Mark 12:38-44
33rd Sunday in Ordinary Time (Year B)
Date: Sunday, November 17th, 2024, 11:00Old Testament: 1 Sam. 1:4-20
Psalms: 1 Sam. 2:1-10
New Testament: Heb. 10:11-25
Gospel: Mark 13:1-8
Christ the King (Year B)
Date: Sunday, November 24th, 2024, 11:00Old Testament: 2 Sam. 23:1-7
Psalms: Ps. 132:1-18
New Testament: Rev. 1:4-8
Gospel: John 18:33-37
1st Sunday of Advent (Year C)
Date: Sunday, December 01st, 2024, 11:00Old Testament: Jer. 33:14-16
Psalms: Ps. 25:1-10
New Testament: 1 Thess. 3:9-13
Gospel: Luke 21:25-36
2nd Sunday of Advent (Year C)
Date: Sunday, December 08th, 2024, 11:00Old Testament: Mal. 3:1-4
Psalms: Ps. 126
New Testament: Philip. 1:3-11
Gospel: Luke 3:1-6
3rd Sunday of Advent (Year C)
Date: Sunday, December 15th, 2024, 11:00Old Testament: Zeph. 3:14-20
Psalms: Isa. 12:2-6
New Testament: Philip. 4:4-7
Gospel: Luke 3:7-18
4th Sunday of Advent (Year C)
Date: Sunday, December 22nd, 2024, 11:00Old Testament: Micah 5:2-5
Psalms: Ps. 80:1-7
New Testament: Heb. 10:5-10
Gospel: Luke 1:39-55
Christmas Eve (Year C)
Date: Tuesday, December 24th, 2024, 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 C)
Date: Wednesday, December 25th, 2024, 08:00Old Testament: Isa. 62:6-12
Psalms: Ps. 97
New Testament: Titus 3:4-7
Gospel: Luke 2:1-20
Christmas Day (Year C)
Date: Wednesday, December 25th, 2024, 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 C)
Date: Sunday, December 29th, 2024, 11:00Old Testament: 1 Sam. 2:18-20,26
Psalms: Ps. 148
New Testament: Col. 3:12-17
Gospel: Luke 2:41-52
Here is the Lectionary object source code. It may run out to the right a bit.
<?php
/*
##################################################
#
# Filename..........: $RCSfile: Lectionary.php,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; # four digit year
var $cycle; # A, B, or C lectionary cycle
var $first_sunday; # Unix timestamp
var $easter_sunday; # Unix timestamp
var $advent_sunday; # Unix timestamp
var $sunday_after_epiphany; # Unix timestamp
var $calendar; # Array of dates and data
var $lectionary; # XML of lectionary
/*
* Class initialization
*/
function __construct($year='') {
global $_SERVER;
global $_SESSION;
global $_REQUEST;
global $_POST;
global $_GET;
$this->set_year($year);
}
function __destruct()
{
}
/*
* Sets the year or the current year if nothing is passed
*/
function set_year($year='') {
if ( $year == '' ) {
$this->year = gmstrftime("%Y", gmmktime(time()));
} else {
$this->year = $year;
}
// Define the key annual dates
$this->set_first_sunday();
$this->set_easter_sunday();
$this->set_advent_sunday();
$this->set_sunday_after_epiphany();
$this->load_lectionary();
$this->generate_calendar();
}
/*
* Load the lectionary from XML
*/
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);
}
}
/*
* Set the timestamp for the first sunday of the year
*/
function set_first_sunday() {
$dow = intval(gmstrftime("%w", gmmktime(11,0,0,1,1,intval($this->year))));
if ( $dow == 0 ) { $dow = 7; }
$delta = 7 - $dow;
$this->first_sunday = intval(gmmktime(11,0,0,1,1+$delta,intval($this->year)));
}
/*
* Set the timestamp for Easter in a given year
*/
function set_easter_sunday() {
$this->easter_sunday = intval(gmmktime(11,0,0,3,21+easter_days(intval($this->year)),intval($this->year)));
}
/*
* Set the timestamp for the first Sunday in advent
*/
function set_advent_sunday() {
$dow = intval(gmstrftime("%w", gmmktime(11,0,0,12,25,intval($this->year))));
if ( $dow == 0 ) { $dow = 7; }
$delta = -28 + ( 7 - $dow );
$this->advent_sunday = intval(gmmktime(11,0,0,12,25+$delta,intval($this->year)));
}
/*
* Set the timestamp for the first sunday after Epiphany (Jan 6)
*/
function set_sunday_after_epiphany() {
$dow = intval(gmstrftime("%w", gmmktime(11,0,0,1,6,intval($this->year))));
if ( $dow == 0 ) {
$delta = 7;
} else {
$delta = 7 - $dow;
}
$this->sunday_after_epiphany = intval(gmmktime(11,0,0,1,6+$delta,intval($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->first_sunday == gmmktime(11,0,0,1,1,intval($this->year)) ) {
$this->calendar[$this->first_sunday] = '8'; # First Sunday after Christmas Day
} else {
$this->calendar[$this->first_sunday] = '9'; # Second Sunday after Christmas Day
}
$this->calendar[gmmktime(11,0,0,1,6,intval($this->year))] = '10'; # Epiphany of the Lord
$this->calendar[$this->sunday_after_epiphany] = '11'; # Baptism of the Lord
$this->calendar[$this->easter_sunday-(49*$day)] = '12'; # Transfiguration Sunday
$this->calendar[$this->easter_sunday-(46*$day)] = '13'; # Ash Wednesday
$this->calendar[$this->easter_sunday-(42*$day)] = '14'; # First Sunday in Lent
$this->calendar[$this->easter_sunday-(35*$day)] = '15'; # Second Sunday in Lent
$this->calendar[$this->easter_sunday-(28*$day)] = '16'; # Third Sunday in Lent
$this->calendar[$this->easter_sunday-(21*$day)] = '17'; # Fourth Sunday in Lent
$this->calendar[$this->easter_sunday-(14*$day)] = '18'; # Fifth Sunday in Lent
$this->calendar[$this->easter_sunday-(7*$day)] = '19'; # Palm/Passion Sunday
$this->calendar[$this->easter_sunday-(6*$day)] = '20'; # Monday of Holy Week
$this->calendar[$this->easter_sunday-(5*$day)] = '21'; # Tuesday of Holy Week
$this->calendar[$this->easter_sunday-(4*$day)] = '22'; # Wednesday of Holy Week
$this->calendar[$this->easter_sunday-(3*$day)] = '23'; # Maundy Thursday
$this->calendar[$this->easter_sunday-(2*$day)] = '24'; # Good Friday
$this->calendar[$this->easter_sunday-(1*$day)] = '25'; # Holy Saturday
$this->calendar[$this->easter_sunday] = '26'; # Easter Sunday
$this->calendar[$this->easter_sunday+(8*60*60)] = '27'; # Easter Evening
$this->calendar[$this->easter_sunday+(7*$day)] = '28'; # Second Sunday of Easter
$this->calendar[$this->easter_sunday+(14*$day)] = '29'; # Third Sunday of Easter
$this->calendar[$this->easter_sunday+(21*$day)] = '30'; # Fourth Sunday of Easter
$this->calendar[$this->easter_sunday+(28*$day)] = '31'; # Fifth Sunday of Easter
$this->calendar[$this->easter_sunday+(35*$day)] = '32'; # Sixth Sunday of Easter
$this->calendar[$this->easter_sunday+(39*$day)] = '33'; # Ascension Sunday
$this->calendar[$this->easter_sunday+(42*$day)] = '34'; # Seventh Sunday of Easter
$this->calendar[$this->easter_sunday+(49*$day)] = '35'; # Day of Pentecost
$this->calendar[$this->easter_sunday+(56*$day)] = '36'; # Trinity Sunday
$this->calendar[gmmktime(8, 0, 0, 11, 1, intval($this->year))] = '37'; # All Saint's Day
$this->calendar[$this->advent_sunday-(7*$day)] = '38'; # Christ the King Sunday
$this->calendar[$this->advent_sunday] = '1'; # First Sunday in Advent
$this->calendar[$this->advent_sunday+(7*$day)] = '2'; # Second Sunday in Advent
$this->calendar[$this->advent_sunday+(14*$day)] = '3'; # Third Sunday in Advent
$this->calendar[$this->advent_sunday+(21*$day)] = '4'; # Fourth Sunday in Advent
$this->calendar[gmmktime(21, 0, 0, 12, 24, intval($this->year))] = '5'; # Christmas Eve
$this->calendar[gmmktime(8, 0, 0, 12, 25, intval($this->year))] = '6'; # Christmas Day (Sunrise)
$this->calendar[gmmktime(11, 0, 0, 12, 25, intval($this->year))] = '7'; # Christmas Day
if ( 0 != intval(gmstrftime("%w", gmmktime(11,0,0,12,25,intval($this->year)))) ) {
$this->calendar[$this->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->sunday_after_epiphany+(7*$day); $i<$this->easter_sunday-(49*$day); $i=$i+(7*$day) ) {
if ( $this->calendar[$i] == '' ) {
$this->calendar[$i] = $index; # Sundays after Epiphany
$index++;
}
}
# Variable Sundays after Pentecost counting backwards from 33rd sunday in Ordinary Time
$index=70;
for ( $i=$this->advent_sunday-(14*$day); $i>$this->easter_sunday+(56*$day); $i=$i-(7*$day) ) {
if ( $this->calendar[$i] == '' ) {
$this->calendar[$i] = $index; # Sundays after Pentecost
$index--;
}
}
ksort($this->calendar);
}
/*
* Get the calendar array
*/
function get_calendar()
{
return($this->calendar);
}
/*
* Get the long format date for a given unix timestamp
*/
function get_long_date($unixdate) {
$s = get_day_suffix(intval(gmstrftime("%d",$unixdate)));
return gmstrftime("%A, %B %d<sup>$s</sup>, %Y, %H:%M", $unixdate );
}
function get_calendar_day($unixdate)
{
$year = gmstrftime('%Y',$unixdate);
$month = gmstrftime('%m',$unixdate);
$day = gmstrftime('%d',$unixdate);
$day_start = gmmktime(0,0,0,intval($month),intval($day),intval($year));
$day_end = gmmktime(23,59,59,intval($month),intval($day),intval($year));
$result = array();
foreach ( $this->calendar as $key => $val) {
if ( $key >= $day_start && $key <= $day_end ) {
$result[$key] = $val;
}
}
return($result);
}
/*
* Get the lectionary cycle for a given date
*/
function get_cycle($unixdate) {
$y = array('A','B','C','A');
$year = gmstrftime("%Y", $unixdate);
$mod = ( ($year-1) % 3 );
if ( $unixdate < $this->advent_sunday ) {
return($y[$mod]);
} else {
return($y[$mod+1]);
}
}
/*
* Get the title for a given date and index
*/
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);
}
/*
* Get the scripture for a given date, index, and lesson (old, psalms, new, gospel)
*/
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);
}
}
?>