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 2018

Epiphany of the Lord (Year B)

Date: Saturday, January 06th, 2018, 11:00
Old 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, 2018, 11:00
Old 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, 2018, 11:00
Old 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, 2018, 11:00
Old 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, 2018, 11:00
Old 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, 2018, 11:00
Old 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, 2018, 11:00
Old 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, 2018, 11:00
Old 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, 2018, 11:00
Old 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, 2018, 11:00
Old 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 04th, 2018, 11:00
Old 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 11th, 2018, 11:00
Old 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 18th, 2018, 11:00
Old 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 25th, 2018, 11:00
Old 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 26th, 2018, 11:00
Old 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 27th, 2018, 11:00
Old 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 28th, 2018, 11:00
Old 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 29th, 2018, 11:00
Old 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 30th, 2018, 11:00
Old 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 31st, 2018, 11:00
Old 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, April 01st, 2018, 11:00
Old 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, April 01st, 2018, 19:00
Old 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 08th, 2018, 11:00
Old 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 15th, 2018, 11:00
Old 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 22nd, 2018, 11:00
Old 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 29th, 2018, 11:00
Old 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 06th, 2018, 11:00
Old 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 10th, 2018, 11:00
Old 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 13th, 2018, 11:00
Old 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 20th, 2018, 11:00
Old 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 27th, 2018, 11:00
Old 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 03rd, 2018, 11:00
Old 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 10th, 2018, 11:00
Old 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 17th, 2018, 11:00
Old 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 24th, 2018, 11:00
Old 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, July 01st, 2018, 11:00
Old 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 08th, 2018, 11:00
Old 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 15th, 2018, 11:00
Old 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 22nd, 2018, 11:00
Old 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 29th, 2018, 11:00
Old 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 05th, 2018, 11:00
Old 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 12th, 2018, 11:00
Old 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 19th, 2018, 11:00
Old 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 26th, 2018, 11:00
Old 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 02nd, 2018, 11:00
Old 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 09th, 2018, 11:00
Old 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 16th, 2018, 11:00
Old 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 23rd, 2018, 11:00
Old 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 30th, 2018, 11:00
Old 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 07th, 2018, 11:00
Old 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 14th, 2018, 11:00
Old 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 21st, 2018, 11:00
Old 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 28th, 2018, 11:00
Old 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: Thursday, November 01st, 2018, 08:00
Old 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 04th, 2018, 11:00
Old 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 11th, 2018, 11:00
Old 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 18th, 2018, 11:00
Old 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 25th, 2018, 11:00
Old 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 02nd, 2018, 11:00
Old 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 09th, 2018, 11:00
Old 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 16th, 2018, 11:00
Old 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 23rd, 2018, 11:00
Old 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: Monday, December 24th, 2018, 21:00
Old 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: Tuesday, December 25th, 2018, 08:00
Old Testament: Isa. 62:6-12
Psalms: Ps. 97
New Testament: Titus 3:4-7
Gospel: Luke 2:1-20

Christmas Day (Year C)

Date: Tuesday, December 25th, 2018, 11:00
Old 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 30th, 2018, 11:00
Old 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.


<?
/*
##################################################
#
# 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) % );
    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 == ) { $dow 7; }
    
$delta $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 == ) {
      
$delta 7;
    } else {
      
$delta $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 == ) { $dow 7; }
    
$delta = -28 + ( $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(110016$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(800111$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(21001224$this->year)] = '5'# Christmas Eve
    
$this->calendar[gmmktime(8001225$this->year)]  = '6'# Christmas Day (Sunrise)
    
$this->calendar[gmmktime(11001225$this->year)] = '7'# Christmas Day
    
if ( != 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);
  }

}

?>