You are here

function cmfcCalendarV1Thai::date in Calendar Systems 8.2

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

Implementation of PHP date function This is the simplified versino by Sina Salek

Overrides cmfcCalendarV1Plugin::date

2 calls to cmfcCalendarV1Thai::date()
cmfcCalendarV1Thai::smartGet in calendar/v1/calendarSystems/thai.class.inc.php
Placeholder for smartGet function.
cmfcCalendarV1Thai::timestampToStr in calendar/v1/calendarSystems/thai.class.inc.php

File

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

Class

cmfcCalendarV1Thai

Code

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;
}