peckrob/episcopaldate

此类包含了一些静态方法,主要处理美国圣公会(全球圣公宗的美国分支)的日期。作为西方基督教传统,这些功能也适用于其他教派。

dev-master 2015-03-26 19:01 UTC

This package is auto-updated.

Last update: 2024-09-22 17:30:26 UTC


README

EpiscopalDate 是一个小的 PHP 类,包含了一系列用于计算美国圣公会(全球圣公宗的美国分支)的日期和日历的静态方法。作为西方基督教传统,其中许多功能也适用于其他教派。

我写这个作为我教会网站重写的部分,并认为它可能对其他人也很有用。

  • 计算复活节、 Advent、主显节、圣枝主日、耶稣受难日和圣灵降临节的日期。
  • 基于修订的共同诵读经文和通用祈祷书计算礼仪年。
  • 生成完整的礼仪日历。

需求

PHP 5.3+

安装

此类遵循 PSR-4 自动加载规范并使用命名空间。如果你使用 composer,安装很简单。只需将以下内容添加到你的 composer.json 文件中的 require 行

"peckrob/episcopaldate": "dev-master"

或者,你可以下载这个类并直接使用。它没有依赖。

使用

使用这个类很简单。所有日期函数都返回 UNIX 时间戳,可以使用内置的 PHP date() 函数格式化。

use EpiscopalDate\EpiscopalDate;

$easter_date = EpiscopalDate::easterDate(2014);
echo date("Y-m-d", $easter_date);
// Outputs 2014-04-20.

完整方法参考

/**
 * Calculates the date of Easter on the Gregorian Calendar. This is based on
 * a function found in the comments here:
 * 
 * https://php.ac.cn/manual/en/function.easter-date.php
 * 
 * @param   int     $year   The year. If omitted, the current year.
 * @return  int             A timestamp representing Easter. 
 */
public static function easterDate($year = "");

/**
 * Calculates the date for Ash Wednesday, which is 46 days before Easter.
 * 
 * @param   int     $year   The year. If omitted, the current year.
 * @return  int             A timestamp representing Ash Wednesday. 
 */
public static function ashWednesdayDate($year = "");

/**
 * Calculates the date of Mandy Thursday, which occurrs three days before 
 * Easter.
 * 
 * @param   int     $year   The year. If omitted, the current year.
 * @return  int             A timestamp representing Mandy Thursday. 
 */
public static function maundyThursdayDate($year = "");

/**
 * Calculates the date of Good Friday, which occurrs two days before Easter.
 * 
 * @param   int     $year   The year. If omitted, the current year.
 * @return  int             A timestamp representing Good Friday. 
 */
public static function goodFridayDate($year = "");

/**
 * Calculates the date for Palm Sunday, the Sunday before Easter.
 * 
 * @param   int     $year   The year. If omitted, the current year.
 * @return  int             A timestamp representing Palm Sunday. 
 */
public static function palmSundayDate($year = "");

/**
 * Calculates the date of Pentecost, 7 weeks after Easter.
 * 
 * @param   int     $year   The year. If omitted, the current year.
 * @return  int             A timestamp representing Pentecost. 
 */
public static function pentecostDate($year = "");

/**
 * Calculates the date of Advent, which is defined as the 4th Sunday before 
 * Christmas.
 * 
 * @param   int     $year   The year. If omitted, the current year.
 * @return  int             A timestamp representing the first Sunday of 
 *                          Advent. 
 */
public static function adventDate($year = "");

/**
 * Calculates the Episcopal Liturgial Church Year, based on a date. The 
 * liturgical year begins on Advent.
 * 
 * @param   int     $timestamp  A timestamp.
 * @return  string              One of A, B, C.
 */
public static function liturgicalYear($timestamp = "");

/**
 * Returns a string representing the liturgical season.
 * 
 * @param   int     $timestamp  A timestamp.
 * @return  string              The liturgical season.
 */
public static function liturgicalSeason($timestamp = "");

/**
 * Returns the liturgical week.
 * 
 * @param   int     $timestamp  A timestamp.
 * @return  string              The current liturgical week.
 */
public static function liturgicalWeek($timestamp = "");

/**
 * Generages a full liturgical calendar, with the keys as the sundays of 
 * each week and the values as the liturgical season and week.
 * 
 * @param   int     $year   The year. If omitted, the current year.
 * @return type 
 */
public static function liturgicalCalendar($year);

许可证

MIT