You are here

class cmfcCalendarV1Thai in Calendar Systems 6

Same name and namespace in other branches
  1. 8 calendar/v1/calendarSystems/thai.class.inc.php \cmfcCalendarV1Thai
  2. 8.2 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 5

View source
class cmfcCalendarV1Thai extends cmfcCalendarV1 {
  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 mktime(0, 0, 0, $info['month'], $info['day'], $info['year']);
  }
  function dateDiff($first, $second) {
    $first_date = explode('-', $first);
    $first_date = mktime(0, 0, 0, $first_date[1], $first_date[2], $first_date[0]);
    $second_date = explode('-', $second);
    $second_date = mktime(0, 0, 0, $second_date[1], $second_date[2], $second_date[0]);
    $totalasec = $second_date - $first_date;
    return $totalday = round($totalsec / 86400);
  }
  function date($format, $timestamp) {
    if (is_null($timestamp) || $timestamp == '') {
      $timestamp = $this
        ->phpTime();
    }
    $value = gmdate($format, $timestamp);
    switch ($format) {
      case 'D':
        $output = $this
          ->getWeekShortName(gmdate('w', $timestamp));
        break;
      case 'l':
        $output = $this
          ->getWeekName(gmdate('w', $timestamp));
        break;
      case 'S':
        $output = '';

        /* In Thai has no suffix.*/
        break;
      case 'F':
        $output = $this
          ->getMonthName(gmdate('n', $timestamp));
        break;
      case 'M':
        $output = $this
          ->getMonthShortName(gmdate('n', $timestamp));
        break;
      case 'Y':
        $output = $value + 543;
        break;
      case 'y':
        $output = (string) $value + 543;
        $output = substr($output, strlen($output) - 2);
        break;
      case 'U':
        $output = $this
          ->phpTime();
        break;
      default:
        $output = gmdate($format, $timestamp);
        break;
    }
    return $output;
  }
  function isDateValid($month, $day, $year) {
    $month = (int) $month;
    $day = (int) $day;
    $year = (int) $year - 543;
    $timestamp = 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;
  }

  /**
   * 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];
  }

}

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 function
cmfcCalendarV1::getYmdwMonthAsNavigationalArray function
cmfcCalendarV1::gregorianStrToTimestamp function
cmfcCalendarV1::infoArrayToInfoArray function
cmfcCalendarV1::phpDate function
cmfcCalendarV1::phpGetDate function
cmfcCalendarV1::phpTime function
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
cmfcCalendarV1Thai::dateDiff function
cmfcCalendarV1Thai::getMonthName function translate number of month to name of month
cmfcCalendarV1Thai::getMonthShortName function
cmfcCalendarV1Thai::getWeekName function translate number of month to name of month
cmfcCalendarV1Thai::getWeekShortName function
cmfcCalendarV1Thai::infoArrayToTimestamp function Overrides cmfcCalendarV1::infoArrayToTimestamp
cmfcCalendarV1Thai::isDateValid function
cmfcCalendarV1Thai::strToTimestamp function Overrides cmfcCalendarV1::strToTimestamp
cmfcCalendarV1Thai::timestampToInfoArray function Overrides cmfcCalendarV1::timestampToInfoArray
cmfcCalendarV1Thai::timestampToStr function Overrides cmfcCalendarV1::timestampToStr
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 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