Class System_Date
{
var $monthfull_en=array(' January ',' February ',' March ',' April ',' May ',' June ',' July ',' August ',' September ',' October ',' November ',' December ');
var $monthfull_th=array('Á¡ÃÒ¤Á','¡ØÁÀҾѹ¸ì','ÁÕ¹Ò¤Á','àÁÉÒ¹','¾ÄÉÀÒ¤Á','ÁԶعÒ¹','¡Ã¡¯Ò¤Á','ÊÔ§ËÒ¤Á','¡Ñ¹ÂÒ¹','µØÅÒ¤Á','¾ÄȨԡÒ¹','¸Ñ¹ÇÒ¤Á');
var $monthshort_en=array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var $monthshort_th=array('Á.¤.','¡.¾.','ÁÕ.¤.','àÁ.Â.','¾.¤.','ÁÔ.Â.','¡.¤.','Ê.¤.','¡.Â.','µ.¤.','¾.Â.','¸.¤.');
var $montnumber=array('1','2','3','4','5','6','7','8','9','10','11','12');
var $monthdisplay=array('01','02','03','04','05','06','07','08','09','10','11','12');
var $datelist=array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');
var $DateShortTh=array('ÍÒ','¨','Í','¾','¾Ä','È','Ê');
var $DateFullTh=array('ÍÒ·ÔµÂì','¨Ñ¹·Ãì','Íѧ¤ÒÃ','¾Ø¸','¾ÄËÑʺ´Õ','ÈØ¡Ãì','àÊÒÃì');
var $CurrentYear,$CurrentMonth,$CurrentDate;
var $temp,$temp1;
var $DateFormat;
var $SignOfDate,$CurrentDateLanguage;
/*
Update : Thu 1 September,2005 23:26 PM
Description : Function System_Date is define current data or time.
*/
function System_Date()
{
global $System_Date_Format,$System_Date_Language;
$this->CurrentYear=date('Y');
$this->CurrentMonth=date('m');
$this->CurrentDate=date('d');
$this->CurrentDateFormat=$System_Date_Format;
$this->CurrentDateLanguage=$System_Date_Language;
}
/*
Update : Thu 1 September,2005 23:27 PM
Description : Function ListAllMonth is make select object for display month
*/
function ListAllMonth($MonthID)
{
$this->temp="";
for($i=0;$i<count($this->monthfull_en);$i++)
{
$this->temp.="<option value=\"".($i+1)."\"";
if($MonthID==$i){
$this->temp.=" selected";
}
$this->temp.=">".$this->monthfull_en[$i]."</option>".chr(13);
}
return $this->temp;
}
/*
Update : Thu 1 September,2005 23:27 PM
Description : List All year.
*/
function ListAllYear($YearID)
{
$start=date('Y')-40;
$stop=date('Y')+40;
for($i=$start;$i<=$stop;$i++)
{
$this->tempyear.="<option value=\"".$i."\" ";
if($YearID==$i)
{
$this->tempyear.= "selected";
}
$this->tempyear.=">".$i."</option>";
}
return $this->tempyear;
}
/*
Update : Thu 1 September,2005 23:29 PM
Description : List All date
*/
function ListAllDate($DateID)
{
for($i=1;$i<=31;$i++)
{
$this->temp.="<option value=\"".$i."\" ";
if($DateID==$i){
$this->temp.="selected";
}
$this->temp.=">".$i."</option>".chr(13);
}
return $this->temp;
}
function DateFormate($DateTime,$Format)
{
if($DateTime=="0000-00-00 00:00:00" || empty($DateTime)) { return "N/A"; }
$myDate = split("00:00:00",$DateTime);
$myTime = explode(" ",$DateTime);
$myDates = split("-",$myDate[0]);
switch($Format)
{
case "ThaiFormat1" : return $this->DateThaiFormat($myDates[2],$myDates[1],$myDates[0]); break;
case "ThaiFormat2" : return $this->DateThaiFormat1($myDates[2],$myDates[1],$myDates[0]); break;
case "ThaiFormat3" : return $this->DateThaiFormat2($myDates[2],$myDates[1],$myDates[0],$myTime[1]); break;
case "ThaiFormat4" : return $this->DateThaiFormat3($myDates[2],$myDates[1],$myDates[0],$myTime[1]); break;
case "ThaiFormat5" : return $this->DateThaiFormat4($myDates[2],$myDates[1],$myDates[0]); break;
case "EngFormat1" : return $this->DateEngFormat1($myDates[2],$myDates[1],$myDates[0]); break;
case "Short" : return $myDate[0]; break;
}
}
function DateEngFormat1($Day,$Month,$Year)
{
// 14/07/2006
return $Day."/".$Month."/".$Year;
}
function DateThaiFormat($Day,$Month,$Year)
{
$this->temp = ($Day*1)." ".$this->monthfull_th[($Month*1)-1]." ".($Year+543);
return $this->temp;
}