You are here

interface DatexCalendarIterface in Datex 7.2

A calendar class extending DatexObject should implement this interface to function correctly. An example implemention is DatexJalali.

Hierarchy

Expanded class hierarchy of DatexCalendarIterface

All classes that implement DatexCalendarIterface

File

datex_api/datex_api.class.inc, line 35
Provides an API to work with dates.

View source
interface DatexCalendarIterface {

  /**
   * Methos responsible for converting Gregorian date to localized date.
   *
   * @return array
   *   Array containing converted date, Array should be indexed from 0 to 7 in
   *   this order: year, month, day, hour, minute, month, day of year (number
   *   of days passed since day 1 of that year), day of week. Day of week MUST
   *   be from 1 to 7.
   */
  public static function convert($timestamp, $offset = 0);

  /**
   * Opposite of DatexCalendarIterface::convert().
   */
  public static function toGregorian($year = 0, $month = 0, $day = 0);

  /**
   * Will calculate whether the localized year is leap year or not.
   */
  public static function isLeap($year);

  /**
   * Returns various information used by DatexObject.
   *
   * For an example look at DatexJalali.
   *
   * Required information are:
   *   intl_args: array of arguments passed to IntlDateFormatter.
   *   First, second, third and fifth arguments of IntlDateFormatter
   *   constructor should be put in array in order.
   *
   *   numbers: Associative array of localized numbers in calendar's language.
   *   from 0 to 9 in array.
   *
   *   names: Name of dates.
   *
   *   month_days: Number of days in each month of year, NOT counting leap
   *   years.
   */
  public function getInfo($name);

  /**
   * To override format charachters DatexObject can't or shouldn't handle.
   *
   * Shoud return an associative array keyed by date format charachter and it's
   * value as formatted date (the date is available from the onject instance).
   */
  function calendarFormat();

  /**
   * Day of week calculated from given year and day of year.
   */
  public static function dayOfWeek($year, $dayOfYear = 0);

  /**
   * Provides an array containing default arguments for INTL formatter.
   */
  function getIntlArgs();

  /**
   * Helper function to make up for missing granularities.
   *
   * While converting dates, If some granularities are missing, It's needed to
   * add some amount to timestamp, To have some final conversion correct.
   * You see, Date module with only year, will store time as 2013-1-1, But it's
   * not obvious user meant 1392 or 1391?
   * Why? half of 2013 is 1392 (from march to december) and half is 1391, (from
   * january to april). But this month is lost after it's converted to 2013-1-1.
   * A fixed amount of time, (equal to choped off) amount of time, needs to be
   * added each time. I hope I could explain it well! I guess not.
   *
   * Special handling is needed for when day is present and month is not and is
   * not supported by this method.
   */
  function fixMissingGranularities(array $granuls);

}

Members

Namesort descending Modifiers Type Description Overrides
DatexCalendarIterface::calendarFormat function To override format charachters DatexObject can't or shouldn't handle. 2
DatexCalendarIterface::convert public static function Methos responsible for converting Gregorian date to localized date. 2
DatexCalendarIterface::dayOfWeek public static function Day of week calculated from given year and day of year. 2
DatexCalendarIterface::fixMissingGranularities function Helper function to make up for missing granularities. 1
DatexCalendarIterface::getInfo public function Returns various information used by DatexObject. 2
DatexCalendarIterface::getIntlArgs function Provides an array containing default arguments for INTL formatter. 2
DatexCalendarIterface::isLeap public static function Will calculate whether the localized year is leap year or not. 2
DatexCalendarIterface::toGregorian public static function Opposite of DatexCalendarIterface::convert(). 2