function cmfcCalendarV1Julian::date in Calendar Systems 8.2
Same name and namespace in other branches
- 8 calendar/v1/calendarSystems/julian.class.inc.php \cmfcCalendarV1Julian::date()
- 7 calendar/v1/calendarSystems/julian.class.inc.php \cmfcCalendarV1Julian::date()
- 7.2 calendar/v1/calendarSystems/julian.class.inc.php \cmfcCalendarV1Julian::date()
Implementation of PHP date function This is the simplified versino by Sina Salek
Overrides cmfcCalendarV1Plugin::date
2 calls to cmfcCalendarV1Julian::date()
- cmfcCalendarV1Julian::smartGet in calendar/
v1/ calendarSystems/ julian.class.inc.php - @desc accept array,timestamp and string as input datetime in jalali or gregorian format
- cmfcCalendarV1Julian::timestampToInfoArray in calendar/
v1/ calendarSystems/ julian.class.inc.php
File
- calendar/
v1/ calendarSystems/ julian.class.inc.php, line 137
Class
Code
function date($format, $maket = null) {
$farsi = 1;
$type = $format;
//set 1 if you want translate number to farsi or if you don't like set 0
$transnumber = false;
///chosse your timezone
$TZhours = 0;
$TZminute = 0;
$need = "";
$result1 = "";
$result = "";
if (is_null($maket)) {
$year = $this
->phpDate("Y");
$month = $this
->phpDate("m");
$day = $this
->phpDate("d");
$maket = parent::mktime($this
->phpDate("H") + $TZhours, $this
->phpDate("i") + $TZminute, $this
->phpDate("s"), $this
->phpDate("m"), $this
->phpDate("d"), $this
->phpDate("Y"));
}
else {
$maket += $TZhours * 3600 + $TZminute * 60;
$year = $this
->phpDate("Y", $maket);
$month = $this
->phpDate("m", $maket);
$day = $this
->phpDate("d", $maket);
}
$need = $maket;
$i = 0;
$subtype = "";
$subtypetemp = "";
list($jyear, $jmonth, $jday) = $this
->fromGregorian($year, $month, $day);
while ($i < strlen($type)) {
$subtype = substr($type, $i, 1);
if ($subtype == "\\") {
$subtypetemp = $subtype;
$i++;
continue;
}
elseif ($subtypetemp == "\\") {
$result .= $subtype;
$subtypetemp = $subtype;
$i++;
continue;
}
else {
$subtypetemp = $subtype;
$i++;
}
switch ($subtype) {
case "A":
$result1 = $this
->phpDate("a", $need);
$result .= $this
->getMeridiemName($result1);
break;
case "a":
$result1 = $this
->phpDate("a", $need);
$result .= $this
->getMeridiemShortName($result1);
case "d":
if ($jday < 10) {
$result1 = "0" . $jday;
}
else {
$result1 = $jday;
}
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "D":
$result1 = $this
->phpDate("w", $need);
$result .= $this
->getWeekShortName($result1);
break;
case "F":
$result .= $this
->getMonthName($jmonth);
break;
case "g":
$result1 = $this
->phpDate("g", $need);
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "G":
$result1 = $this
->phpDate("G", $need);
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "h":
$result1 = $this
->phpDate("h", $need);
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "H":
$result1 = $this
->phpDate("H", $need);
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "i":
$result1 = $this
->phpDate("i", $need);
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "j":
$result1 = $jday;
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "l":
$result1 = $this
->phpDate("w", $need);
$result .= $this
->getWeekName($result1);
break;
case "m":
if ($jmonth < 10) {
$result1 = "0" . $jmonth;
}
else {
$result1 = $jmonth;
}
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "M":
$result .= $this
->getMonthShortName($jmonth);
break;
case "n":
$result1 = $jmonth;
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "s":
$result1 = $this
->phpDate("s", $need);
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "S":
$result .= 'ام';
break;
case "t":
$result .= $this
->monthTotalDays($month, $day, $year);
break;
case "w":
$result1 = $this
->phpDate("w", $need);
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "y":
$result1 = substr($jyear, 2, 4);
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "Y":
$result1 = $jyear;
if ($transnumber == 1) {
$result .= cmfcString::convertNumbersToFarsi($result1);
}
else {
$result .= $result1;
}
break;
case "O":
$result .= $this
->phpDate('O', $need);
break;
case "P":
$result .= $this
->phpDate('P', $need);
break;
case "T":
$result .= $this
->phpDate('T', $need);
break;
case "U":
$result .= $this
->phpDate();
break;
case "Z":
$result .= $this
->yearTotalDays($jmonth, $jday, $jyear);
break;
case "L":
list($tmp_year, $tmp_month, $tmp_day) = $this
->toGregorian(1384, 12, 1);
/*
echo $tmp_day;
if(lastday($tmp_month,$tmp_day,$tmp_year)=="31")
$result.="1";
else
$result.="0";
*/
break;
default:
$result .= $subtype;
}
}
return $result;
}