<?php /*****************************************************************************************************************/
/************************************************ DATE FORMAT CLASS **********************************************/
/*****************************************************************************************************************/
/**
* @author Pavel Zheltakov <PavelZ@5ci.lt>
* @version v1.5 2003.05.16
* @copyright Copyright � 2003, Pavel Zheltakov
*
* This class formats data in english, lithuanian and russian languages. Exp. Monday, 12 April, 2003.
* Compares two dates in format mm/dd/yyyy
*/
class date_format {
/* Class vars */
var $yearT;
var $month;
var $monthT;
var $month_r;
var $month_l;
var $monthdayT;
var $weekday;
var $weekdayT;
var $weekday_r;
var $weekday_l;
var $data_full;
/* Constructor*/
function date_format ()
{
$this->yearT = date("Y");
$this->monthT = date("n");
$this->monthdayT = date("j");
$this->weekdayT = date("w");
}
/* Gets current date */
function get_tooday($lang)
{
$this->lang = $lang;
/* Array of weekdays */
$this->weekday = array(
0 => "Sunday",
1 => "Monday",
2 => "Tuesday",
3 => "Wednesday",
4 => "Thursday",
5 => "Friday",
6 => "Saturday"
);
$this->weekday_r = array(
0 => "?????�?�??�",
1 => "???���?�???",
2 => "???????",
3 => "??��?",
4 => "��??�??",
5 => "?????�?",
6 => "?�?????"
);
$this->weekday_l = array(
0 => "Sekmadienis",
1 => "Pirmadienis",
2 => "Antradienis",
3 => "Tre?iadienis",
4 => "Ketvirtadienis",
5 => "Penktadienis",
6 => "?e?tadienis",
);
/* Arrays of months */
$this->month = array(
1 => "January",
2 => "February",
3 => "March",
4 => "April",
5 => "May",
6 => "June",
7 => "July",
8 => "August",
9 => "September",
10 => "October",
11 => "November",
12 => "December"
);
$this->month_r = array(
1 => "�?????",
2 => "?�?????",
3 => "?????",
4 => "???�??",
5 => "???",
6 => "????",
7 => "????",
8 => "???�???",
9 => "?�??????",
10 => "???????",
11 => "??????",
12 => "��?????"
);
$this->month_l = array(
1 => "Sausio",
2 => "Vasario",
3 => "Kovo",
4 => "Baland?io",
5 => "Gegu??s",
6 => "Bir?elio",
7 => "Liepos",
8 => "Rugpj??io",
9 => "Rugs?jo",
10 => "Spalio",
11 => "Lapkri?io",
12 => "Gruod?io"
);
/* do the concatenation for showing full date */
switch($this->lang)
{
case "lit" :
$this->data_full = $this->weekday_l[$this->weekdayT].", ".$this->yearT." m. ".$this->month_l[$this->monthT]." ".$this->monthdayT." d.";
break;
case "eng" :
$this->data_full = $this->weekday[$this->weekdayT].", ".$this->yearT." y. ".$this->month[$this->monthT]." ".$this->monthdayT." d.";
break;
case "rus" :
$this->data_full = $this->weekday_r[$this->weekdayT].", ".$this->monthdayT." ".$this->month_r[$this->monthT]." ".$this->yearT." ??.";
break;
default :
$this->data_full = $this->weekday_l[$this->weekdayT].", ".$this->yearT." ".$this->month_l[$this->monthT]." ".$this->monthdayT;
break;
}
return $data_full;
}
/* Do the comparison of two dates in format : mm/dd/yyyy */
function compare_two_dates($data1, $data2)
{
$this->data1 = $data1;
$this->data2 = $data2;
list($this->month1, $this->day1, $this->year1) = explode("/", $this->data1);
list($this->month2, $this->day2, $this->year2) = explode("/", $this->data2);
$this->timestamp1 = mktime(0, 0, 0, $this->month1, $this->day1, $this->year1);
$this->timestamp2 = mktime(0, 0, 0, $this->month2, $this->day2, $this->year2);
if($this->timestamp1 > $this->timestamp2)
{
print "The bigger date is : ".$this->data1;
}
else
{
print "The bigger date is : ".$this->data2;
}
}
/* Prints current date depending on selected lang */
function show_date()
{
print $this->data_full;
}
} ?>
|
|