|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZDateUtils class 00004 // 00005 // Created on: <05-May-2004 11:51:15 amos> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! \file ezdateutils.php 00032 */ 00033 00034 /*! 00035 \class eZDateUtils ezdateutils.php 00036 \brief The class eZDateUtils does 00037 00038 */ 00039 00040 class eZDateUtils 00041 { 00042 /*! 00043 \static 00044 Return a textual representation of the date according to the RFC 1123 standard. 00045 00046 rfc1123-date = wkday "," SP date1 SP time SP "GMT" 00047 date1 = 2DIGIT SP month SP 4DIGIT 00048 ; day month year (e.g., 02 Jun 1982) 00049 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 00050 ; 00:00:00 - 23:59:59 00051 wkday = "Mon" | "Tue" | "Wed" 00052 | "Thu" | "Fri" | "Sat" | "Sun" 00053 month = "Jan" | "Feb" | "Mar" | "Apr" 00054 | "May" | "Jun" | "Jul" | "Aug" 00055 | "Sep" | "Oct" | "Nov" | "Dec" 00056 */ 00057 static function rfc1123Date( $timestamp = false ) 00058 { 00059 if ( $timestamp === false ) 00060 $timestamp = time(); 00061 $wday = (int) gmdate( 'w', $timestamp ); 00062 $days = array( 1 => 'Mon', 2 => 'Tue', 3 => 'Wed', 00063 4 => 'Thu', 5 => 'Fri', 6 => 'Sat', 0 => 'Sun' ); 00064 $wkday = $days[$wday]; 00065 $month = (int) gmdate( 'n', $timestamp ); 00066 $months = array( 1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 00067 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 00068 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec' ); 00069 00070 $mon = $months[$month]; 00071 return gmstrftime( $wkday . ", %d " . $mon . " %Y %H:%M:%S" . " GMT", $timestamp ); 00072 } 00073 00074 /*! 00075 \static 00076 Return a textual representation of the date according to the RFC 850 standard. 00077 00078 rfc850-date = weekday "," SP date2 SP time SP "GMT" 00079 date2 = 2DIGIT "-" month "-" 2DIGIT 00080 ; day-month-year (e.g., 02-Jun-82) 00081 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 00082 ; 00:00:00 - 23:59:59 00083 wkday = "Mon" | "Tue" | "Wed" 00084 | "Thu" | "Fri" | "Sat" | "Sun" 00085 weekday = "Monday" | "Tuesday" | "Wednesday" 00086 | "Thursday" | "Friday" | "Saturday" | "Sunday" 00087 month = "Jan" | "Feb" | "Mar" | "Apr" 00088 | "May" | "Jun" | "Jul" | "Aug" 00089 | "Sep" | "Oct" | "Nov" | "Dec" 00090 */ 00091 static function rfc850Date( $timestamp = false ) 00092 { 00093 if ( $timestamp === false ) 00094 $timestamp = time(); 00095 $wday = (int) gmdate( 'w', $timestamp ); 00096 $days = array( 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 00097 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday', 0 => 'Sunday' ); 00098 $weekday = $days[$wday]; 00099 $month = (int) gmdate( 'n', $timestamp ); 00100 $months = array( 1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 00101 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 00102 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec' ); 00103 $mon = $months[$month]; 00104 return gmstrftime( $weekday . ", %d-" . $mon . "-%Y %H:%M:%S" . " GMT", $timestamp ); 00105 } 00106 00107 /*! 00108 \static 00109 Parses the date \a $dateText which is in text format and returns a timestamp which represents that date. 00110 */ 00111 static function textToDate( $dateText ) 00112 { 00113 return strtotime( $dateText ); 00114 } 00115 } 00116 00117 ?>