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: 3.9.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 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 Constructor 00044 */ 00045 function eZDateUtils() 00046 { 00047 } 00048 00049 /*! 00050 \static 00051 Return a textual representation of the date according to the RFC 1123 standard. 00052 00053 rfc1123-date = wkday "," SP date1 SP time SP "GMT" 00054 date1 = 2DIGIT SP month SP 4DIGIT 00055 ; day month year (e.g., 02 Jun 1982) 00056 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 00057 ; 00:00:00 - 23:59:59 00058 wkday = "Mon" | "Tue" | "Wed" 00059 | "Thu" | "Fri" | "Sat" | "Sun" 00060 month = "Jan" | "Feb" | "Mar" | "Apr" 00061 | "May" | "Jun" | "Jul" | "Aug" 00062 | "Sep" | "Oct" | "Nov" | "Dec" 00063 */ 00064 function rfc1123Date( $timestamp = false ) 00065 { 00066 if ( $timestamp === false ) 00067 $timestamp = mktime(); 00068 $wday = (int) gmdate( 'w', $timestamp ); 00069 $days = array( 1 => 'Mon', 2 => 'Tue', 3 => 'Wed', 00070 4 => 'Thu', 5 => 'Fri', 6 => 'Sat', 0 => 'Sun' ); 00071 $wkday = $days[$wday]; 00072 $month = (int) gmdate( 'n', $timestamp ); 00073 $months = array( 1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 00074 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 00075 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec' ); 00076 00077 $mon = $months[$month]; 00078 return gmstrftime( $wkday . ", %d " . $mon . " %Y %H:%M:%S" . " GMT", $timestamp ); 00079 } 00080 00081 /*! 00082 \static 00083 Return a textual representation of the date according to the RFC 850 standard. 00084 00085 rfc850-date = weekday "," SP date2 SP time SP "GMT" 00086 date2 = 2DIGIT "-" month "-" 2DIGIT 00087 ; day-month-year (e.g., 02-Jun-82) 00088 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 00089 ; 00:00:00 - 23:59:59 00090 wkday = "Mon" | "Tue" | "Wed" 00091 | "Thu" | "Fri" | "Sat" | "Sun" 00092 weekday = "Monday" | "Tuesday" | "Wednesday" 00093 | "Thursday" | "Friday" | "Saturday" | "Sunday" 00094 month = "Jan" | "Feb" | "Mar" | "Apr" 00095 | "May" | "Jun" | "Jul" | "Aug" 00096 | "Sep" | "Oct" | "Nov" | "Dec" 00097 */ 00098 function rfc850Date( $timestamp = false ) 00099 { 00100 if ( $timestamp === false ) 00101 $timestamp = mktime(); 00102 $wday = (int) gmdate( 'w', $timestamp ); 00103 $days = array( 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 00104 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday', 0 => 'Sunday' ); 00105 $weekday = $days[$wday]; 00106 $month = (int) gmdate( 'n', $timestamp ); 00107 $months = array( 1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 00108 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 00109 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec' ); 00110 $mon = $months[$month]; 00111 return gmstrftime( $weekday . ", %d-" . $mon . "-%Y %H:%M:%S" . " GMT", $timestamp ); 00112 } 00113 00114 /*! 00115 \static 00116 Parses the date \a $dateText which is in text format and returns a timestamp which represents that date. 00117 */ 00118 function textToDate( $dateText ) 00119 { 00120 return strtotime( $dateText ); 00121 } 00122 } 00123 00124 ?>
1.6.3