You are here

class cmfcCalendarV1Thai in Calendar Systems 8.2

Same name and namespace in other branches
  1. 8 calendar/v1/calendarSystems/thai.class.inc.php \cmfcCalendarV1Thai
  2. 6 calendar/v1/calendarSystems/thai.class.inc.php \cmfcCalendarV1Thai
  3. 7 calendar/v1/calendarSystems/thai.class.inc.php \cmfcCalendarV1Thai
  4. 7.2 calendar/v1/calendarSystems/thai.class.inc.php \cmfcCalendarV1Thai

Hierarchy

Expanded class hierarchy of cmfcCalendarV1Thai

File

calendar/v1/calendarSystems/thai.class.inc.php, line 6

View source
class cmfcCalendarV1Thai extends cmfcCalendarV1 implements cmfcCalendarV1Plugin {
  var $_monthsName = array(
    '1' => 'มกราคม',
    '2' => 'กุมภาพันธ์',
    '3' => 'มีนาคม',
    '4' => 'เมษายน',
    '5' => 'พฤษภาคม',
    '6' => 'มิถุนายน',
    '7' => 'กรกฎาคม',
    '8' => 'สิงหาคม',
    '9' => 'กันยายน',
    '10' => 'ตุลาคม',
    '11' => 'พฤศจิกายน',
    '12' => 'ธันวาคม',
  );
  var $_monthsShortName = array(
    '1' => 'ม.ค.',
    '2' => 'ก.พ.',
    '3' => 'มี.ค.',
    '4' => 'เม.ย.',
    '5' => 'พ.ค.',
    '6' => 'มิ.ย.',
    '7' => 'ก.ค.',
    '8' => 'ส.ค.',
    '9' => 'ก.ย.',
    '10' => 'ต.ค.',
    '11' => 'พ.ย.',
    '12' => 'ธ.ค.',
  );
  var $_weeksName = array(
    '0' => 'อาทิตย์',
    '1' => 'จันทร์',
    '2' => 'อังคาร',
    '3' => 'พุธ',
    '4' => 'พฤหัสบดี',
    '5' => 'ศุกร์',
    '6' => 'เสาร์',
  );
  var $_weeksShortName = array(
    '0' => 'อา',
    '1' => 'จ',
    '2' => 'อ',
    '3' => 'พ',
    '4' => 'พฤ',
    '5' => 'ศ',
    '6' => 'ส',
  );
  var $_weekDaysHoliday = array(
    6,
    0,
  );
  function timestampToStr($format, $timestamp = NULL) {
    if (is_null($timestamp)) {
      $timestamp = time();

      //$this->phpTime();
    }
    return $this
      ->date($format, $timestamp);
  }
  function strToTimestamp($string) {
    $date = explode(' ', $string);
    $date_parts = explode('-', $date[0]);
    $date_parts[0] = $date_parts[0] - 543;
    $date[0] = implode('-', $date_parts);
    $date = implode(' ', $date);
    return strtotime($date);
  }
  function timestampToInfoArray($timestamp = NULL) {
    if (is_null($timestamp)) {
      $timestamp = $this
        ->phpTime();
    }
    $info = $this
      ->phpGetDate($timestamp);
    $info['month'] = $info['mon'];
    $info['day'] = $info['mday'];
    $info['monthName'] = $this
      ->getMonthName($info['month']);
    $info['monthShortName'] = $this
      ->getMonthShortName($info['month']);
    $info_timestamp = $this
      ->infoArrayToTimestamp(array(
      'year' => $info['year'],
      'month' => $info['month'],
      'day' => 1,
    ));
    $info['monthFirstDayWeekday'] = $this
      ->phpDate('w', $info_timestamp) + 1;
    $info['monthDaysNumber'] = $this
      ->phpDate('t', $timestamp);
    $info['weekday'] = $info['wday'];
    $info['weekdayName'] = $this
      ->getWeekName($info['weekday']);
    $info['weekdayShortName'] = $this
      ->getWeekShortName($info['weekday']);
    return $info;
  }
  function infoArrayToTimestamp($info) {
    return parent::mktime(0, 0, 0, $info['month'], $info['day'], $info['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]);
    $second_date = explode('-', $second);
    $second_date = parent::mktime(0, 0, 0, $second_date[1], $second_date[2], $second_date[0]);
    $totalasec = $second_date - $first_date;
    return $totalday = round($totalasec / 86400);
  }
  function date($format, $timestamp = NULL) {
    if (is_null($timestamp) || $timestamp == '') {
      $timestamp = $this
        ->phpTime();
    }
    $value = $this
      ->phpDate($format, $timestamp);
    $letters = preg_split('//', $format);
    array_shift($letters);
    array_pop($letters);
    $year = $this
      ->phpDate('Y', $timestamp) + 543;
    $output = '';
    $prvLetter = '';
    foreach ($letters as $letter) {
      if ($letter == "\\") {
        $prvLetter = $letter;
        continue;
      }
      elseif ($prvLetter == "\\") {
        $output .= $letter;
        $prvLetter = $letter;
        continue;
      }
      $prvLetter = $letter;
      switch ($letter) {
        case 'D':
          $output .= $this
            ->getWeekShortName($this
            ->phpDate('w', $timestamp));
          break;
        case 'l':
          $output .= $this
            ->getWeekName($this
            ->phpDate('w', $timestamp));
          break;
        case 'S':
          $output .= '';

          /* In Thai has no suffix.*/
          break;
        case 'F':
          $output .= $this
            ->getMonthName($this
            ->phpDate('n', $timestamp));
          break;
        case 'M':
          $output .= $this
            ->getMonthShortName($this
            ->phpDate('n', $timestamp));
          break;
        case 'Y':
          $output .= $year;
          break;
        case 'y':
          $output .= substr((string) $year, 2);
          break;
        case 'U':
          $output .= $this
            ->phpTime();
          break;
        case ' ':
          $output .= ' ';
          break;
        default:
          $output .= $this
            ->phpDate($letter, $timestamp);
          break;
      }
    }
    return $output;
  }
  function smartGet($format, $timestamp = NULL) {
    return $this
      ->date($format, $timestamp);
  }
  function fromGregorian($year, $month, $day) {
    return NULL;
  }
  function toGregorian($year, $month, $day) {
    return array(
      (int) $year - 543,
      $month,
      $day,
    );
  }

  /**
   * accept array,timestamp and string as input datetime in jalali
   * or gregorian format and convert it to timestamp
   * Implementation of PHP strtotime function
   */
  function strtotime($value) {
    return NULL;
  }
  function isDateValid($month, $day, $year) {
    $month = (int) $month;
    $day = (int) $day;
    $year = (int) $year - 543;
    $timestamp = parent::mktime(10, 10, 10, $month, $day, $year);
    if ($month < 1 || $month > 12) {
      return FALSE;
    }
    if ($year < 1970 || $year > date('Y', $timestamp)) {
      return FALSE;
    }
    if ($day < 1 || $day > date('t', $timestamp)) {
      return FALSE;
    }
    return TRUE;
  }
  function makeTime($hour = "", $minute = "", $second = "", $jmonth = "", $jday = "", $jyear = "") {
    if (!$hour && !$minute && !$second && !$jmonth && !$jmonth && !$jday && !$jyear) {
      return $this
        ->phpTime();
    }
    list($year, $month, $day) = $this
      ->toGregorian($jyear, $jmonth, $jday);
    $i = parent::mktime($hour, $minute, $second, $month, $day, $year);
    return $i;
  }

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

  /**
   * translate number of month to name of month
   */
  function getMonthName($month) {
    return $this->_monthsName[$month];
  }
  function getMonthShortName($month) {
    return $this->_monthsShortName[$month];
  }

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

}

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::dateTimeDiff function Date : 15-12-2003. 1
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
cmfcCalendarV1Thai::$_monthsName property
cmfcCalendarV1Thai::$_monthsShortName property
cmfcCalendarV1Thai::$_weekDaysHoliday property
cmfcCalendarV1Thai::$_weeksName property
cmfcCalendarV1Thai::$_weeksShortName property
cmfcCalendarV1Thai::date function Implementation of PHP date function This is the simplified versino by Sina Salek Overrides cmfcCalendarV1Plugin::date
cmfcCalendarV1Thai::dateDiff function Overrides cmfcCalendarV1Plugin::dateDiff
cmfcCalendarV1Thai::fromGregorian function Overrides cmfcCalendarV1Plugin::fromGregorian
cmfcCalendarV1Thai::getMonthName function translate number of month to name of month
cmfcCalendarV1Thai::getMonthShortName function
cmfcCalendarV1Thai::getStrings function Get list of translatable strings Overrides cmfcCalendarV1::getStrings
cmfcCalendarV1Thai::getWeekName function translate number of month to name of month
cmfcCalendarV1Thai::getWeekShortName function
cmfcCalendarV1Thai::infoArrayToTimestamp function Overrides cmfcCalendarV1::infoArrayToTimestamp
cmfcCalendarV1Thai::isDateValid function Overrides cmfcCalendarV1Plugin::isDateValid
cmfcCalendarV1Thai::makeTime function Overrides cmfcCalendarV1Plugin::makeTime
cmfcCalendarV1Thai::smartGet function Placeholder for smartGet function. Overrides cmfcCalendarV1::smartGet
cmfcCalendarV1Thai::strtotime function accept array,timestamp and string as input datetime in jalali or gregorian format and convert it to timestamp Implementation of PHP strtotime function Overrides cmfcCalendarV1Plugin::strtotime
cmfcCalendarV1Thai::strToTimestamp function Overrides cmfcCalendarV1::strToTimestamp
cmfcCalendarV1Thai::timestampToInfoArray function Overrides cmfcCalendarV1::timestampToInfoArray
cmfcCalendarV1Thai::timestampToStr function Overrides cmfcCalendarV1::timestampToStr
cmfcCalendarV1Thai::toGregorian function Overrides cmfcCalendarV1Plugin::toGregorian
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