You are here

class cmfcCalendarV1Gregorian in Calendar Systems 8

Same name and namespace in other branches
  1. 8.2 calendar/v1/calendarSystems/gregorian.class.inc.php \cmfcCalendarV1Gregorian
  2. 5 calendar/v1/calendarSystems/gregorian.class.inc.php \cmfcCalendarV1Gregorian
  3. 6.3 calendar/v1/calendarSystems/gregorian.class.inc.php \cmfcCalendarV1Gregorian
  4. 6 calendar/v1/calendarSystems/gregorian.class.inc.php \cmfcCalendarV1Gregorian
  5. 7.3 calendar/v1/calendarSystems/gregorian.class.inc.php \cmfcCalendarV1Gregorian
  6. 7 calendar/v1/calendarSystems/gregorian.class.inc.php \cmfcCalendarV1Gregorian
  7. 7.2 calendar/v1/calendarSystems/gregorian.class.inc.php \cmfcCalendarV1Gregorian

@desc

Hierarchy

Expanded class hierarchy of cmfcCalendarV1Gregorian

File

calendar/v1/calendarSystems/gregorian.class.inc.php, line 13

View source
class cmfcCalendarV1Gregorian extends cmfcCalendarV1 implements cmfcCalendarV1Plugin {
  var $_monthsName = array(
    '1' => 'January',
    '2' => 'February',
    '3' => 'March',
    '4' => 'April',
    '5' => 'May',
    '6' => 'June',
    '7' => 'July',
    '8' => 'August',
    '9' => 'September',
    '10' => 'October',
    '11' => 'November',
    '12' => 'December',
  );
  var $_monthsShortName = array(
    '1' => 'Jan',
    '2' => 'Feb',
    '3' => 'Mar',
    '4' => 'Apr',
    '5' => 'May',
    '6' => 'Jun',
    '7' => 'Jul',
    '8' => 'Aug',
    '9' => 'Sep',
    '10' => 'Oct',
    '11' => 'Nov',
    '12' => 'Dec',
  );
  var $_weeksName = array(
    '0' => 'Sunday',
    //Sunday
    '1' => 'Monday',
    '2' => 'Tuesday',
    '3' => 'Wednesday',
    '4' => 'Thursday',
    '5' => 'Friday',
    '6' => 'Saturday',
  );
  var $_weeksShortName = array(
    '0' => 'Sun',
    //Sunday
    '1' => 'Mon',
    '2' => 'Tu',
    '3' => 'We',
    '4' => 'Th',
    '5' => 'Fr',
    '6' => 'Sa',
  );
  var $_meridiemsName = array(
    'am' => 'AM',
    'pm' => 'PM',
  );
  var $_meridiemsShortName = array(
    'am' => 'AM',
    'pm' => 'PM',
  );
  var $_weekDaysHoliday = array(
    0,
    1,
  );
  function timestampToStr($format, $timestamp = null) {
    return parent::timestampToStr($format, $timestamp = null);
  }
  function strToTimestamp($string) {
    return parent::strToTimestamp($string);
  }
  function timestampToInfoArray($timestamp = null) {
    if (is_null($timestamp)) {
      $timestamp = $this
        ->phpTime();
    }
    $arr = $this
      ->phpGetDate($timestamp);
    $arr['month'] = $arr['mon'];
    $arr['day'] = $arr['mday'];
    $arr['monthName'] = $this
      ->getMonthName($arr['month']);
    $arr['monthShortName'] = $this
      ->getMonthShortName($arr['month']);
    $arr['monthFirstDayWeekday'] = $this
      ->phpDate('w', $this
      ->infoArrayToTimestamp(array(
      'year' => $arr['year'],
      'month' => $arr['month'],
      'day' => '1',
    ))) + 1;
    $arr['monthDaysNumber'] = $this
      ->phpDate('t', $timestamp);
    $arr['weekday']++;
    $arr['weekday'] = $arr['wday'];
    $arr['weekdayName'] = $this
      ->getWeekName($arr['weekday']);
    $arr['weekdayShortName'] = $this
      ->getWeekShortName($arr['weekday']);
    return $arr;
  }
  function isDateValid($month, $day, $year) {
    return checkdate($month, $day, $year);
  }
  function infoArrayToTimestamp($arr) {
    return parent::mktime(0, 0, 0, $arr['month'], $arr['day'], $arr['year']);
  }
  function dateDiff($first, $second) {
    $first_date = explode("-", $first);
    $first_date = parent::mktime(0, 0, 0, $first_date[1], $first_date[2], $first_date[0]);

    //echo $first_date[1];
    $second_date = explode("-", $second);
    $second_date = parent::mktime(0, 0, 0, $second_date[1], $second_date[2], $second_date[0]);
    $totalsec = $second_date - $first_date;
    return $totalday = round($totalsec / 86400);
  }

  /**
   * translate number of month to name of month
   */
  function getWeekName($weekNumber) {
    return html_entity_decode($this->_weeksName[$weekNumber]);
  }
  function getWeekShortName($weekNumber) {
    return html_entity_decode($this->_weeksShortName[$weekNumber]);
  }

  /**
   * translate number of month to name of month
   */
  function getMonthName($month) {
    return html_entity_decode($this->_monthsName[$month]);
  }
  function getMonthShortName($month) {
    return html_entity_decode($this->_monthsShortName[$month]);
  }
  function getMeridiemName($m) {
    return html_entity_decode($this->_meridiemsName[$m]);
  }
  function getMeridiemShortName($m) {
    return html_entity_decode($this->_meridiemsShortName[$m]);
  }
  function dateTimeDiff($first_timestamp, $second_timestamp) {

    // Author: Tone.
    // Date    : 15-12-2003.
    // Ref: Dates go in "2003-12-31".
    // Ref: Times go in "12:59:13".
    // Ref: parent::mktime(HOUR,MIN,SEC,MONTH,DAY,YEAR).
    // Splits the dates into parts, to be reformatted for parent::mktime.
    //    $first_datetime = getdate($first_datetime);
    //    $second_datetime = getdate($second_datetime);
    // makes the dates and times into unix timestamps.
    // $first_unix  = parent::mktime($first_datetime['hours'], $first_time_ex[1], $first_time_ex[2], $first_date_ex[1], $first_date_ex[2], $first_date_ex[0]);
    // $second_unix  = parent::mktime($second_time_ex[0], $second_time_ex[1], $second_time_ex[2], $second_date_ex[1], $second_date_ex[2], $second_date_ex[0]);
    // Gets the difference between the two unix timestamps.
    if (empty($first_timestamp) or $first_timestamp < 0 or empty($second_timestamp) or $second_timestamp < 0) {
      return false;
    }
    $timediff = $first_timestamp - $second_timestamp;

    // Works out the days, hours, mins and secs.
    $days = intval($timediff / 86400);
    $remain = $timediff % 86400;
    $hours = intval($remain / 3600);
    $remain = $remain % 3600;
    $mins = intval($remain / 60);
    $secs = $remain % 60;

    // Returns a pre-formatted string. Can be chagned to an array.
    $result['days'] = $days;
    $result['hours'] = $hours;
    $result['minutes'] = $mins;
    return $result;
  }
  function jGetDate($timestamp = "", $transNumber = 1) {
    if ($timestamp == "") {
      $timestamp = $this
        ->phpTime();
    }
    return array(
      0 => $timestamp,
      "seconds" => jdate("s", $timestamp, $transNumber),
      "minutes" => jdate("i", $timestamp, $transNumber),
      "hours" => jdate("G", $timestamp, $transNumber),
      "mday" => jdate("j", $timestamp, $transNumber),
      "wday" => jdate("w", $timestamp, $transNumber),
      "mon" => jdate("n", $timestamp, $transNumber),
      "year" => jdate("Y", $timestamp, $transNumber),
      "yday" => cmfcDateTime::yearTotalDays(jdate("m", $timestamp, $transNumber), jdate("d", $timestamp, $transNumber), jdate("Y", $timestamp, $transNumber)),
      "weekday" => jdate("l", $timestamp, $transNumber),
      "month" => jdate("F", $timestamp, $transNumber),
    );
  }
  function change_to_miladi($date) {
    $date = explode("-", $date);
    $date = cmfcDateTime::jalaliToGregorian($date[0], $date[1], $date[2]);

    //$date[1] = $date[1] -1;
    $date = $date[0] . "-" . $date[1] . "-15";
    return $date;
  }
  function date_fa($date) {
    list($year, $month, $day) = preg_split('/-/', $date);
    list($jyear, $jmonth, $jday) = cmfcDateTime::gregorianToJalali($year, $month, $day);
    $date = jmaketime(0, 0, 0, $jmonth, $jday, $jyear);
    $date = jdate("d M Y", $date);
    return $date;
  }
  function date_en($date) {
    $date = explode("-", $date);
    $date = date("F j, Y", parent::mktime(0, 0, 0, $date[1], $date[2], $date[0]));
    return $date;
  }
  function dateByLanguage($format, $time_stamp, $lang) {
    if ($lang == 'fa') {
      return cmfcJalaliDateTime::smartGet($format, $time_stamp, 1);
    }
    else {
      return date($format, cmfcJalaliDateTime::toTimeStamp($time_stamp));
    }
  }

  /**
   * Get list of translatable strings
   */
  function getStrings() {
    $stringGroups = array(
      'monthsName' => array(
        'en' => $this->_monthsName,
      ),
      'monthsShortName' => array(
        'en' => $this->_monthsShortName,
      ),
      'weeksName' => array(
        'en' => $this->_weeksName,
      ),
      'weeksShortName' => array(
        'en' => $this->_weeksShortName,
      ),
      'meridiemsName' => array(
        'en' => $this->_meridiemsName,
      ),
      'meridiemsShortName' => array(
        'en' => $this->_meridiemsShortName,
      ),
    );
    return $stringGroups;
  }

  /**
   * Implementation of PHP date function
   * This is the simplified versino by Sina Salek
   */
  public function date($format, $maket = null) {
    return parent::phpDate($format, $maket = null);
  }
  public function strtotime($value) {
    return strtotime($value);
  }
  public function fromGregorian($g_y, $g_m, $g_d) {
    return array(
      $g_y,
      $g_m,
      $g_d,
    );
  }
  public function toGregorian($j_y, $j_m, $j_d) {
    return array(
      $j_y,
      $j_m,
      $j_d,
    );
  }
  public function valueToTimeStamp($y, $m, $d, $h, $i, $s) {
    return $value = strtotime("{$y}-{$m}-{$d} {$h}:{$i}:{$s}");
  }

  /**
   * @desc accept array,timestamp and string as input datetime in jalali or gregorian format
   */
  public function smartGet($type, $value = "now") {
    return parent::smartGet($type, $value);
  }
  public function makeTime($hour = "", $minute = "", $second = "", $jmonth = "", $jday = "", $jyear = "") {
    return parent::mktime($hour, $minute, $second, $jmonth, $jday, $jyear);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
cmfcCalendarV1::$_defaultError property Overrides cmfcClassesCoreStandAlone::$_defaultError
cmfcCalendarV1::$_language property Overrides cmfcClassesCoreStandAlone::$_language
cmfcCalendarV1::$_messagesValue property Overrides cmfcClassesCoreStandAlone::$_messagesValue
cmfcCalendarV1::$_name property
cmfcCalendarV1::$_timeZoneInfo property
cmfcCalendarV1::$_timeZoneName property
cmfcCalendarV1::countDown function * For supporting timezone , use this class date and time functions like phpDate
cmfcCalendarV1::factory static function
cmfcCalendarV1::getAllStrings function * Get list of translatable strings
cmfcCalendarV1::getPlugins function
cmfcCalendarV1::getYmdwMonthAsNavigationalArray function
cmfcCalendarV1::gregorianStrToTimestamp function
cmfcCalendarV1::infoArrayToInfoArray function
cmfcCalendarV1::mktime function * For backward compatibility with PHP 4.x - 5.1
cmfcCalendarV1::phpDate function
cmfcCalendarV1::phpGetDate function
cmfcCalendarV1::phpTime function
cmfcCalendarV1::replaceVariables function $replacements['00username00']='jafar gholi';
cmfcCalendarV1::secondsToDays function convert seconds to days,hours,minuts,seconds as array
cmfcCalendarV1::setOption function * @NOTICE child classed definition should apply the byReference version of function * Overrides cmfcClassesCoreStandAlone::setOption
cmfcCalendarV1::setTimeZoneOffset function
cmfcCalendarV1::__construct function
cmfcCalendarV1Gregorian::$_meridiemsName property
cmfcCalendarV1Gregorian::$_meridiemsShortName property
cmfcCalendarV1Gregorian::$_monthsName property
cmfcCalendarV1Gregorian::$_monthsShortName property
cmfcCalendarV1Gregorian::$_weekDaysHoliday property
cmfcCalendarV1Gregorian::$_weeksName property
cmfcCalendarV1Gregorian::$_weeksShortName property
cmfcCalendarV1Gregorian::change_to_miladi function
cmfcCalendarV1Gregorian::date public function Implementation of PHP date function This is the simplified versino by Sina Salek Overrides cmfcCalendarV1Plugin::date
cmfcCalendarV1Gregorian::dateByLanguage function
cmfcCalendarV1Gregorian::dateDiff function Overrides cmfcCalendarV1Plugin::dateDiff
cmfcCalendarV1Gregorian::dateTimeDiff function Date : 15-12-2003. Overrides cmfcCalendarV1::dateTimeDiff
cmfcCalendarV1Gregorian::date_en function
cmfcCalendarV1Gregorian::date_fa function
cmfcCalendarV1Gregorian::fromGregorian public function Overrides cmfcCalendarV1Plugin::fromGregorian
cmfcCalendarV1Gregorian::getMeridiemName function
cmfcCalendarV1Gregorian::getMeridiemShortName function
cmfcCalendarV1Gregorian::getMonthName function translate number of month to name of month
cmfcCalendarV1Gregorian::getMonthShortName function
cmfcCalendarV1Gregorian::getStrings function Get list of translatable strings Overrides cmfcCalendarV1::getStrings
cmfcCalendarV1Gregorian::getWeekName function translate number of month to name of month
cmfcCalendarV1Gregorian::getWeekShortName function
cmfcCalendarV1Gregorian::infoArrayToTimestamp function Overrides cmfcCalendarV1::infoArrayToTimestamp
cmfcCalendarV1Gregorian::isDateValid function Overrides cmfcCalendarV1Plugin::isDateValid
cmfcCalendarV1Gregorian::jGetDate function
cmfcCalendarV1Gregorian::makeTime public function Overrides cmfcCalendarV1Plugin::makeTime
cmfcCalendarV1Gregorian::smartGet public function @desc accept array,timestamp and string as input datetime in jalali or gregorian format Overrides cmfcCalendarV1::smartGet
cmfcCalendarV1Gregorian::strtotime public function Implementation of PHP strtotime function Overrides cmfcCalendarV1Plugin::strtotime
cmfcCalendarV1Gregorian::strToTimestamp function Overrides cmfcCalendarV1::strToTimestamp
cmfcCalendarV1Gregorian::timestampToInfoArray function Overrides cmfcCalendarV1::timestampToInfoArray
cmfcCalendarV1Gregorian::timestampToStr function Overrides cmfcCalendarV1::timestampToStr
cmfcCalendarV1Gregorian::toGregorian public function Overrides cmfcCalendarV1Plugin::toGregorian
cmfcCalendarV1Gregorian::valueToTimeStamp public function
cmfcClassesCoreStandAlone::$_commandHandlers property
cmfcClassesCoreStandAlone::$_commandingEnabled property
cmfcClassesCoreStandAlone::$_debugEnabled property
cmfcClassesCoreStandAlone::$_dynamicSystemEnabled property
cmfcClassesCoreStandAlone::$_errorsStack property
cmfcClassesCoreStandAlone::$_observeringEnabled property
cmfcClassesCoreStandAlone::$_observers property
cmfcClassesCoreStandAlone::$_oLog property * Log object used for error logging by ErrorStack * * * @access public
cmfcClassesCoreStandAlone::$_options property
cmfcClassesCoreStandAlone::$_oStorage property *
cmfcClassesCoreStandAlone::$_version property
cmfcClassesCoreStandAlone::addCommandHandler function * @example * <code> * $object->addCommandHandler('commandName','functionName') * $object->addCommandHandler('commandName',array(&$myObject,'methodName')) * </code>
cmfcClassesCoreStandAlone::addObserver function Register the reference to an object object
cmfcClassesCoreStandAlone::arrayToProperties function
cmfcClassesCoreStandAlone::clearProperties function
cmfcClassesCoreStandAlone::cmfcClassesCore function * there is no __construct function in php4 or down , so this function is solution , now it's possible * for all chid of this base class to have __construct functions *
cmfcClassesCoreStandAlone::getCalculatedLocations function * This function calculates the base location of package in filesystem and in browser * This is a critical function for other packages to work properly * By default it points to the real path when symlinks are used * * Site with subdomain…
cmfcClassesCoreStandAlone::getMessageValue function
cmfcClassesCoreStandAlone::getOption function * works fine in both php4 & 5. but you should use & when you call the function. $b=&$ins->getOption('property')
cmfcClassesCoreStandAlone::getVersion function
cmfcClassesCoreStandAlone::hasCommandHandler function
cmfcClassesCoreStandAlone::isError public static function
cmfcClassesCoreStandAlone::notifyObservers function Calls the update() function using the reference to each registered observer - used by children of Observable
cmfcClassesCoreStandAlone::prependCommandHandler function
cmfcClassesCoreStandAlone::prependObserver function
cmfcClassesCoreStandAlone::propertiesToArray function
cmfcClassesCoreStandAlone::raiseError function raise an error @example <code> return $this->raiseError('', CMF_Language_Error_Unknown_Short_Name, * CMF_ERROR_RETURN,NULL, * array('shortName'=>$shortName) * ); </code>
cmfcClassesCoreStandAlone::removeCommandHandlers function
cmfcClassesCoreStandAlone::removeObservers function
cmfcClassesCoreStandAlone::resetProperties function * fill all of object variables with their default values except $base_properties * $base_properties=array('local_language_name','db','event_system','configurations','table_name_prefix'); *…
cmfcClassesCoreStandAlone::restoreFromMemento function memento design pattern will load the object previous state @todo - should become complete
cmfcClassesCoreStandAlone::runCommand function * @example * <code> * $this->runCommand('sendEmailAfterActivation',$columnsValues); * </code>
cmfcClassesCoreStandAlone::saveToMemento function memento design pattern will clone the object for adding undo ability. @todo - should become complete
cmfcClassesCoreStandAlone::setLog function
cmfcClassesCoreStandAlone::setOptionByReference function
cmfcClassesCoreStandAlone::setOptions function * @NOTICE child classed definition should apply the byReference version of function * to pass by reference to work correctly * @NOTICE $options[$name] is require for PHP4,PHP5 compatibility *
cmfcClassesCoreStandAlone::setOptionsByReference function
cmfcClassesCoreStandAlone::setStorage function