Lectionary Class

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 2025

2nd Sunday after Christmas Day (Year C)

Date: Sunday, January 05th, 2025, 11:00
Old 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: Monday, January 06th, 2025, 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 C)

Date: Sunday, January 12th, 2025, 11:00
Old 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 19th, 2025, 11:00
Old 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 26th, 2025, 11:00
Old 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, February 02nd, 2025, 11:00
Old 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 09th, 2025, 11:00
Old Testament: Isa. 6:1-13
Psalms: Ps. 138
New Testament: 1 Cor. 15:1-11
Gospel: Luke 5:1-11

6th Sunday in Ordinary Time (Year C)

Date: Sunday, February 16th, 2025, 11:00
Old Testament: Jer. 17:5-10
Psalms: Ps. 1
New Testament: 1 Cor. 15:12-20
Gospel: Luke 6:17-26

7th Sunday in Ordinary Time (Year C)

Date: Sunday, February 23rd, 2025, 11:00
Old Testament: Gen. 45:3-11,15
Psalms: Ps. 37:1-11,39-40
New Testament: 1 Cor. 15:35-38,42-50
Gospel: Luke 6:27-38

Transfiguration of the Lord (Year C)

Date: Sunday, March 02nd, 2025, 11:00
Old 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, March 05th, 2025, 11:00
Old 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, March 09th, 2025, 11:00
Old 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, March 16th, 2025, 11:00
Old 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 23rd, 2025, 11:00
Old 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 30th, 2025, 11:00
Old 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, April 06th, 2025, 11:00
Old 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, April 13th, 2025, 11:00
Old 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, April 14th, 2025, 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 C)

Date: Tuesday, April 15th, 2025, 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 C)

Date: Wednesday, April 16th, 2025, 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 C)

Date: Thursday, April 17th, 2025, 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 C)

Date: Friday, April 18th, 2025, 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 C)

Date: Saturday, April 19th, 2025, 11:00
Old 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 20th, 2025, 11:00
Old 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 20th, 2025, 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 C)

Date: Sunday, April 27th, 2025, 11:00
Old 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, May 04th, 2025, 11:00
Old 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, May 11th, 2025, 11:00
Old 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 18th, 2025, 11:00
Old 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 25th, 2025, 11:00
Old 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 29th, 2025, 11:00
Old 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, June 01st, 2025, 11:00
Old 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, June 08th, 2025, 11:00
Old 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, June 15th, 2025, 11:00
Old Testament: Prov. 8:1-4,22-31
Psalms: Ps. 8
New Testament: Rom. 5:1-5
Gospel: John 16:12-15

12th Sunday in Ordinary Time (Year C)

Date: Sunday, June 22nd, 2025, 11:00
Old 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 29th, 2025, 11:00
Old 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 06th, 2025, 11:00
Old 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 13th, 2025, 11:00
Old 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 20th, 2025, 11:00
Old 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 27th, 2025, 11:00
Old 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 03rd, 2025, 11:00
Old 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 10th, 2025, 11:00
Old 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 17th, 2025, 11:00
Old 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 24th, 2025, 11:00
Old 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 31st, 2025, 11:00
Old 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 07th, 2025, 11:00
Old 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 14th, 2025, 11:00
Old 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 21st, 2025, 11:00
Old 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 28th, 2025, 11:00
Old 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 05th, 2025, 11:00
Old 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 12th, 2025, 11:00
Old 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 19th, 2025, 11:00
Old 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 26th, 2025, 11:00
Old Testament: Joel 2:23-32
Psalms: Ps. 65
New Testament: 2 Tim. 4:6-8,16-18
Gospel: Luke 18:9-14

All Saints' Day (Year C)

Date: Saturday, November 01st, 2025, 08:00
Old Testament: Dan. 7:1-3,15-18
Psalms: Ps. 149
New Testament: Eph. 1:11-23
Gospel: Luke 6:20-31

31st Sunday in Ordinary Time (Year C)

Date: Sunday, November 02nd, 2025, 11:00
Old 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

32nd Sunday in Ordinary Time (Year C)

Date: Sunday, November 09th, 2025, 11:00
Old 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 16th, 2025, 11:00
Old 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 23rd, 2025, 11:00
Old 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 30th, 2025, 11:00
Old 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 07th, 2025, 11:00
Old 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 14th, 2025, 11:00
Old 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 21st, 2025, 11:00
Old 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: Wednesday, December 24th, 2025, 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 A)

Date: Thursday, December 25th, 2025, 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 A)

Date: Thursday, December 25th, 2025, 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 A)

Date: Sunday, December 28th, 2025, 11:00
Old 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.


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

}

?>