2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
\r
7 * Generic time span handling class for PEAR
\r
9 * PHP versions 4 and 5
\r
13 * Copyright (c) 1997-2005 Leandro Lucarella, Pierre-Alain Joye
\r
14 * All rights reserved.
\r
16 * Redistribution and use in source and binary forms, with or without
\r
17 * modification, are permitted under the terms of the BSD License.
\r
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
\r
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
\r
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
\r
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
\r
23 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
\r
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
\r
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
27 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
30 * POSSIBILITY OF SUCH DAMAGE.
\r
32 * @category Date and Time
\r
34 * @author Leandro Lucarella <llucax@php.net>
\r
35 * @author Pierre-Alain Joye <pajoye@php.net>
\r
36 * @copyright 1997-2006 Leandro Lucarella, Pierre-Alain Joye
\r
37 * @license http://www.opensource.org/licenses/bsd-license.php
\r
39 * @version CVS: $Id: Span.php,v 1.9 2006/11/21 17:38:15 firman Exp $
\r
40 * @link http://pear.php.net/package/Date
\r
41 * @since File available since Release 1.4
\r
48 * Get the Date class
\r
50 require_once 'Date.php';
\r
53 * Get the Date_Calc class
\r
55 require_once 'Date/Calc.php';
\r
61 * Non Numeric Separated Values (NNSV) Input Format.
\r
63 * Input format guessed from something like this:
\r
64 * days<sep>hours<sep>minutes<sep>seconds
\r
65 * Where <sep> is any quantity of non numeric chars. If no values are
\r
66 * given, time span is set to zero, if one value is given, it's used for
\r
67 * hours, if two values are given it's used for hours and minutes and if
\r
68 * three values are given, it's used for hours, minutes and seconds.<br>
\r
70 * '' -> 0, 0, 0, 0 (days, hours, minutes, seconds)<br>
\r
71 * '12' -> 0, 12, 0, 0
\r
72 * '12.30' -> 0, 12, 30, 0<br>
\r
73 * '12:30:18' -> 0, 12, 30, 18<br>
\r
74 * '3-12-30-18' -> 3, 12, 30, 18<br>
\r
75 * '3 days, 12-30-18' -> 3, 12, 30, 18<br>
\r
76 * '12:30 with 18 secs' -> 0, 12, 30, 18<br>
\r
80 define('DATE_SPAN_INPUT_FORMAT_NNSV', 1);
\r
83 // {{{ Global Variables
\r
86 * Default time format when converting to a string.
\r
90 $GLOBALS['_DATE_SPAN_FORMAT'] = '%C';
\r
93 * Default time format when converting from a string.
\r
97 $GLOBALS['_DATE_SPAN_INPUT_FORMAT'] = DATE_SPAN_INPUT_FORMAT_NNSV;
\r
100 // {{{ Class: Date_Span
\r
103 * Generic time span handling class for PEAR
\r
105 * @author Leandro Lucarella <llucax@php.net>
\r
106 * @author Pierre-Alain Joye <pajoye@php.net>
\r
107 * @copyright 1997-2006 Leandro Lucarella, Pierre-Alain Joye
\r
108 * @license http://www.opensource.org/licenses/bsd-license.php
\r
110 * @version Release: 1.4.7
\r
111 * @link http://pear.php.net/package/Date
\r
112 * @since Class available since Release 1.4
\r
144 * Creates the time span object calling the set() method.
\r
146 * @param mixed $time Time span expression.
\r
147 * @param mixed $format Format string to set it from a string or the
\r
148 * second date set it from a date diff.
\r
153 function __construct($time = 0, $format = null)
\r
155 $this->set($time, $format);
\r
162 * Set the time span to a new value in a 'smart' way.
\r
164 * Sets the time span depending on the argument types, calling
\r
165 * to the appropriate setFromXxx() method.
\r
167 * @param mixed $time Time span expression.
\r
168 * @param mixed $format Format string to set it from a string or the
\r
169 * second date set it from a date diff.
\r
171 * @return bool true on success.
\r
173 * @see setFromObject()
\r
174 * @see setFromArray()
\r
175 * @see setFromString()
\r
176 * @see setFromSeconds()
\r
177 * @see setFromDateDiff()
\r
180 function set($time = 0, $format = null)
\r
182 if (is_a($time, 'date_span')) {
\r
183 return $this->copy($time);
\r
184 } elseif (is_a($time, 'date') and is_a($format, 'date')) {
\r
185 return $this->setFromDateDiff($time, $format);
\r
186 } elseif (is_array($time)) {
\r
187 return $this->setFromArray($time);
\r
188 } elseif (is_string($time)) {
\r
189 return $this->setFromString($time, $format);
\r
190 } elseif (is_int($time)) {
\r
191 return $this->setFromSeconds($time);
\r
193 return $this->setFromSeconds(0);
\r
198 // {{{ setFromArray()
\r
201 * Set the time span from an array.
\r
203 * Set the time span from an array. Any value can be a float (but it
\r
204 * has no sense in seconds), for example array(23.5, 20, 0) is
\r
205 * interpreted as 23 hours, .5*60 + 20 = 50 minutes and 0 seconds.
\r
207 * @param array $time Items are counted from right to left. First
\r
208 * item is for seconds, second for minutes, third
\r
209 * for hours and fourth for days. If there are
\r
210 * less items than 4, zero (0) is assumed for the
\r
213 * @return bool True on success.
\r
217 function setFromArray($time)
\r
219 if (!is_array($time)) {
\r
222 $tmp1 = new Date_Span;
\r
223 if (!$tmp1->setFromSeconds(@array_pop($time))) {
\r
226 $tmp2 = new Date_Span;
\r
227 if (!$tmp2->setFromMinutes(@array_pop($time))) {
\r
231 if (!$tmp2->setFromHours(@array_pop($time))) {
\r
235 if (!$tmp2->setFromDays(@array_pop($time))) {
\r
239 return $this->copy($tmp1);
\r
243 // {{{ setFromString()
\r
246 * Set the time span from a string based on an input format.
\r
248 * Set the time span from a string based on an input format. This is
\r
249 * some like a mix of format() method and sscanf() PHP function. The
\r
250 * error checking and validation of this function is very primitive,
\r
251 * so you should be carefull when using it with unknown $time strings.
\r
252 * With this method you are assigning day, hour, minute and second
\r
253 * values, and the last values are used. This means that if you use
\r
254 * something like setFromString('10, 20', '%H, %h') your time span
\r
255 * would be 20 hours long. Allways remember that this method set
\r
256 * <b>all</b> the values, so if you had a $time span 30 minutes long
\r
257 * and you make $time->setFromString('20 hours', '%H hours'), $time
\r
258 * span would be 20 hours long (and not 20 hours and 30 minutes).
\r
259 * Input format options:<br>
\r
260 * <code>%C</code> Days with time, same as "%D, %H:%M:%S".<br>
\r
261 * <code>%d</code> Total days as a float number
\r
262 * (2 days, 12 hours = 2.5 days).<br>
\r
263 * <code>%D</code> Days as a decimal number.<br>
\r
264 * <code>%e</code> Total hours as a float number
\r
265 * (1 day, 2 hours, 30 minutes = 26.5 hours).<br>
\r
266 * <code>%f</code> Total minutes as a float number
\r
267 * (2 minutes, 30 seconds = 2.5 minutes).<br>
\r
268 * <code>%g</code> Total seconds as a decimal number
\r
269 * (2 minutes, 30 seconds = 90 seconds).<br>
\r
270 * <code>%h</code> Hours as decimal number.<br>
\r
271 * <code>%H</code> Hours as decimal number limited to 2 digits.<br>
\r
272 * <code>%m</code> Minutes as a decimal number.<br>
\r
273 * <code>%M</code> Minutes as a decimal number limited to 2 digits.<br>
\r
274 * <code>%n</code> Newline character (\n).<br>
\r
275 * <code>%p</code> Either 'am' or 'pm' depending on the time. If 'pm'
\r
276 * is detected it adds 12 hours to the resulting time
\r
277 * span (without any checks). This is case
\r
279 * <code>%r</code> Time in am/pm notation, same as "%H:%M:%S %p".<br>
\r
280 * <code>%R</code> Time in 24-hour notation, same as "%H:%M".<br>
\r
281 * <code>%s</code> Seconds as a decimal number.<br>
\r
282 * <code>%S</code> Seconds as a decimal number limited to 2 digits.<br>
\r
283 * <code>%t</code> Tab character (\t).<br>
\r
284 * <code>%T</code> Current time equivalent, same as "%H:%M:%S".<br>
\r
285 * <code>%%</code> Literal '%'.<br>
\r
287 * @param string $time String from where to get the time span
\r
289 * @param string $format Format string.
\r
291 * @return bool True on success.
\r
295 function setFromString($time, $format = null)
\r
297 if (is_null($format)) {
\r
298 $format = $GLOBALS['_DATE_SPAN_INPUT_FORMAT'];
\r
300 // If format is a string, it parses the string format.
\r
301 if (is_string($format)) {
\r
305 $day = $hour = $minute = $second = 0;
\r
306 for ($i = 0; $i < strlen($format); $i++) {
\r
307 $char = $format[$i];
\r
308 if ($char == '%') {
\r
309 $nextchar = $format[++$i];
\r
310 switch ($nextchar) {
\r
312 $str .= '%d, %d:%d:%d';
\r
314 $vars, 'day', 'hour', 'minute', 'second');
\r
317 $str .= '%d, %2d:%2d:%2d';
\r
319 $vars, 'day', 'hour', 'minute', 'second');
\r
323 array_push($vars, 'day');
\r
327 array_push($vars, 'day');
\r
331 array_push($vars, 'hour');
\r
335 array_push($vars, 'minute');
\r
339 array_push($vars, 'second');
\r
343 array_push($vars, 'hour');
\r
347 array_push($vars, 'hour');
\r
351 array_push($vars, 'minute');
\r
355 array_push($vars, 'minute');
\r
362 array_push($vars, 'pm');
\r
365 $str .= '%2d:%2d:%2d %2s';
\r
367 $vars, 'hour', 'minute', 'second', 'pm');
\r
371 array_push($vars, 'hour', 'minute');
\r
375 array_push($vars, 'second');
\r
379 array_push($vars, 'second');
\r
385 $str .= '%2d:%2d:%2d';
\r
386 array_push($vars, 'hour', 'minute', 'second');
\r
392 $str .= $char . $nextchar;
\r
398 $vals = sscanf($time, $str);
\r
399 foreach ($vals as $i => $val) {
\r
400 if (is_null($val)) {
\r
405 if (strcasecmp($pm, 'pm') == 0) {
\r
407 } elseif (strcasecmp($pm, 'am') != 0) {
\r
410 $this->setFromArray(array($day, $hour, $minute, $second));
\r
411 // If format is a integer, it uses a predefined format
\r
412 // detection method.
\r
413 } elseif (is_integer($format)) {
\r
415 case DATE_SPAN_INPUT_FORMAT_NNSV:
\r
416 $time = preg_split('/\D+/', $time);
\r
417 switch (count($time)) {
\r
419 return $this->setFromArray(
\r
420 array(0, 0, 0, 0));
\r
422 return $this->setFromArray(
\r
423 array(0, $time[0], 0, 0));
\r
425 return $this->setFromArray(
\r
426 array(0, $time[0], $time[1], 0));
\r
428 return $this->setFromArray(
\r
429 array(0, $time[0], $time[1], $time[2]));
\r
431 return $this->setFromArray($time);
\r
440 // {{{ setFromSeconds()
\r
443 * Set the time span from a total number of seconds.
\r
445 * @param int $seconds Total number of seconds.
\r
447 * @return bool True on success.
\r
451 function setFromSeconds($seconds)
\r
453 if ($seconds < 0) {
\r
456 $sec = intval($seconds);
\r
457 $min = floor($sec / 60);
\r
458 $hour = floor($min / 60);
\r
459 $day = intval(floor($hour / 24));
\r
460 $this->second = $sec % 60;
\r
461 $this->minute = $min % 60;
\r
462 $this->hour = $hour % 24;
\r
468 // {{{ setFromMinutes()
\r
471 * Set the time span from a total number of minutes.
\r
473 * @param float $minutes Total number of minutes.
\r
475 * @return bool True on success.
\r
479 function setFromMinutes($minutes)
\r
481 return $this->setFromSeconds(round($minutes * 60));
\r
485 // {{{ setFromHours()
\r
488 * Set the time span from a total number of hours.
\r
490 * @param float $hours Total number of hours.
\r
492 * @return bool True on success.
\r
496 function setFromHours($hours)
\r
498 return $this->setFromSeconds(round($hours * 3600));
\r
502 // {{{ setFromDays()
\r
505 * Set the time span from a total number of days.
\r
507 * @param float $days Total number of days.
\r
509 * @return bool True on success.
\r
513 function setFromDays($days)
\r
515 return $this->setFromSeconds(round($days * 86400));
\r
519 // {{{ setFromDateDiff()
\r
522 * Set the span from the elapsed time between two dates.
\r
524 * Set the span from the elapsed time between two dates. The time span
\r
525 * is allways positive, so the date's order is not important.
\r
527 * @param object Date $date1 First Date.
\r
528 * @param object Date $date2 Second Date.
\r
530 * @return bool True on success.
\r
534 function setFromDateDiff($date1, $date2)
\r
536 if (!is_a($date1, 'date') or !is_a($date2, 'date')) {
\r
541 if ($date1->after($date2)) {
\r
542 list($date1, $date2) = array($date2, $date1);
\r
544 $days = Date_Calc::dateDiff(
\r
545 $date1->getDay(), $date1->getMonth(), $date1->getYear(),
\r
546 $date2->getDay(), $date2->getMonth(), $date2->getYear()
\r
548 $hours = $date2->getHour() - $date1->getHour();
\r
549 $mins = $date2->getMinute() - $date1->getMinute();
\r
550 $secs = $date2->getSecond() - $date1->getSecond();
\r
551 $this->setFromSeconds(
\r
552 $days * 86400 + $hours * 3600 + $mins * 60 + $secs
\r
561 * Set the time span from another time object.
\r
563 * @param object Date_Span $time Source time span object.
\r
565 * @return bool True on success.
\r
569 function copy($time)
\r
571 if (is_a($time, 'date_span')) {
\r
572 $this->second = $time->second;
\r
573 $this->minute = $time->minute;
\r
574 $this->hour = $time->hour;
\r
575 $this->day = $time->day;
\r
586 * Time span pretty printing (similar to Date::format()).
\r
588 * Formats the time span in the given format, similar to
\r
589 * strftime() and Date::format().<br>
\r
591 * Formatting options:<br>
\r
592 * <code>%C</code> Days with time, same as "%D, %H:%M:%S".<br>
\r
593 * <code>%d</code> Total days as a float number
\r
594 * (2 days, 12 hours = 2.5 days).<br>
\r
595 * <code>%D</code> Days as a decimal number.<br>
\r
596 * <code>%e</code> Total hours as a float number
\r
597 * (1 day, 2 hours, 30 minutes = 26.5 hours).<br>
\r
598 * <code>%E</code> Total hours as a decimal number
\r
599 * (1 day, 2 hours, 40 minutes = 26 hours).<br>
\r
600 * <code>%f</code> Total minutes as a float number
\r
601 * (2 minutes, 30 seconds = 2.5 minutes).<br>
\r
602 * <code>%F</code> Total minutes as a decimal number
\r
603 * (1 hour, 2 minutes, 40 seconds = 62 minutes).<br>
\r
604 * <code>%g</code> Total seconds as a decimal number
\r
605 * (2 minutes, 30 seconds = 90 seconds).<br>
\r
606 * <code>%h</code> Hours as decimal number (0 to 23).<br>
\r
607 * <code>%H</code> Hours as decimal number (00 to 23).<br>
\r
608 * <code>%i</code> Hours as decimal number on 12-hour clock
\r
610 * <code>%I</code> Hours as decimal number on 12-hour clock
\r
612 * <code>%m</code> Minutes as a decimal number (0 to 59).<br>
\r
613 * <code>%M</code> Minutes as a decimal number (00 to 59).<br>
\r
614 * <code>%n</code> Newline character (\n).<br>
\r
615 * <code>%p</code> Either 'am' or 'pm' depending on the time.<br>
\r
616 * <code>%P</code> Either 'AM' or 'PM' depending on the time.<br>
\r
617 * <code>%r</code> Time in am/pm notation, same as "%I:%M:%S %p".<br>
\r
618 * <code>%R</code> Time in 24-hour notation, same as "%H:%M".<br>
\r
619 * <code>%s</code> Seconds as a decimal number (0 to 59).<br>
\r
620 * <code>%S</code> Seconds as a decimal number (00 to 59).<br>
\r
621 * <code>%t</code> Tab character (\t).<br>
\r
622 * <code>%T</code> Current time equivalent, same as "%H:%M:%S".<br>
\r
623 * <code>%%</code> Literal '%'.<br>
\r
625 * @param string $format The format string for returned time span.
\r
627 * @return string The time span in specified format.
\r
631 function format($format = null)
\r
633 if (is_null($format)) {
\r
634 $format = $GLOBALS['_DATE_SPAN_FORMAT'];
\r
637 for ($i = 0; $i < strlen($format); $i++) {
\r
638 $char = $format[$i];
\r
639 if ($char == '%') {
\r
640 $nextchar = $format[++$i];
\r
641 switch ($nextchar) {
\r
643 $output .= sprintf(
\r
644 '%d, %02d:%02d:%02d',
\r
652 $output .= $this->toDays();
\r
655 $output .= $this->day;
\r
658 $output .= $this->toHours();
\r
661 $output .= floor($this->toHours());
\r
664 $output .= $this->toMinutes();
\r
667 $output .= floor($this->toMinutes());
\r
670 $output .= $this->toSeconds();
\r
673 $output .= $this->hour;
\r
676 $output .= sprintf('%02d', $this->hour);
\r
680 ($this->hour + 1) > 12 ?
\r
683 $output .= ($hour == 0) ? 12 : $hour;
\r
687 ($this->hour + 1) > 12 ?
\r
690 $output .= sprintf('%02d', $hour==0 ? 12 : $hour);
\r
693 $output .= $this->minute;
\r
696 $output .= sprintf('%02d',$this->minute);
\r
702 $output .= $this->hour >= 12 ? 'pm' : 'am';
\r
705 $output .= $this->hour >= 12 ? 'PM' : 'AM';
\r
709 ($this->hour + 1) > 12 ?
\r
712 $output .= sprintf(
\r
713 '%02d:%02d:%02d %s',
\r
714 $hour==0 ? 12 : $hour,
\r
717 $this->hour >= 12 ? 'pm' : 'am'
\r
721 $output .= sprintf(
\r
722 '%02d:%02d', $this->hour, $this->minute
\r
726 $output .= $this->second;
\r
729 $output .= sprintf('%02d', $this->second);
\r
735 $output .= sprintf(
\r
737 $this->hour, $this->minute, $this->second
\r
744 $output .= $char . $nextchar;
\r
757 * Convert time span to seconds.
\r
759 * @return int Time span as an integer number of seconds.
\r
763 function toSeconds()
\r
765 return $this->day * 86400 + $this->hour * 3600 +
\r
766 $this->minute * 60 + $this->second;
\r
773 * Convert time span to minutes.
\r
775 * @return float Time span as a decimal number of minutes.
\r
779 function toMinutes()
\r
781 return $this->day * 1440 + $this->hour * 60 + $this->minute +
\r
782 $this->second / 60;
\r
789 * Convert time span to hours.
\r
791 * @return float Time span as a decimal number of hours.
\r
797 return $this->day * 24 + $this->hour + $this->minute / 60 +
\r
798 $this->second / 3600;
\r
805 * Convert time span to days.
\r
807 * @return float Time span as a decimal number of days.
\r
813 return $this->day + $this->hour / 24 + $this->minute / 1440 +
\r
814 $this->second / 86400;
\r
821 * Adds a time span.
\r
823 * @param object Date_Span $time Time span to add.
\r
827 function add($time)
\r
829 return $this->setFromSeconds(
\r
830 $this->toSeconds() + $time->toSeconds()
\r
838 * Subtracts a time span.
\r
840 * Subtracts a time span. If the time span to subtract is larger
\r
841 * than the original, the result is zero (there's no sense in
\r
842 * negative time spans).
\r
844 * @param object Date_Span $time Time span to subtract.
\r
848 function subtract($time)
\r
850 $sub = $this->toSeconds() - $time->toSeconds();
\r
852 $this->setFromSeconds(0);
\r
854 $this->setFromSeconds($sub);
\r
862 * Tells if time span is equal to $time.
\r
864 * @param object Date_Span $time Time span to compare to.
\r
866 * @return bool True if the time spans are equal.
\r
870 function equal($time)
\r
872 return $this->toSeconds() == $time->toSeconds();
\r
876 // {{{ greaterEqual()
\r
879 * Tells if this time span is greater or equal than $time.
\r
881 * @param object Date_Span $time Time span to compare to.
\r
883 * @return bool True if this time span is greater or equal than $time.
\r
887 function greaterEqual($time)
\r
889 return $this->toSeconds() >= $time->toSeconds();
\r
893 // {{{ lowerEqual()
\r
896 * Tells if this time span is lower or equal than $time.
\r
898 * @param object Date_Span $time Time span to compare to.
\r
900 * @return bool True if this time span is lower or equal than $time.
\r
904 function lowerEqual($time)
\r
906 return $this->toSeconds() <= $time->toSeconds();
\r
913 * Tells if this time span is greater than $time.
\r
915 * @param object Date_Span $time Time span to compare to.
\r
917 * @return bool True if this time span is greater than $time.
\r
921 function greater($time)
\r
923 return $this->toSeconds() > $time->toSeconds();
\r
930 * Tells if this time span is lower than $time.
\r
932 * @param object Date_Span $time Time span to compare to.
\r
934 * @return bool True if this time span is lower than $time.
\r
938 function lower($time)
\r
940 return $this->toSeconds() < $time->toSeconds();
\r
947 * Compares two time spans.
\r
949 * Compares two time spans. Suitable for use in sorting functions.
\r
951 * @param object Date_Span $time1 The first time span.
\r
952 * @param object Date_Span $time2 The second time span.
\r
954 * @return int 0 if the time spans are equal, -1 if time1 is lower
\r
955 * than time2, 1 if time1 is greater than time2.
\r
960 function compare($time1, $time2)
\r
962 if ($time1->equal($time2)) {
\r
964 } elseif ($time1->lower($time2)) {
\r
975 * Tells if the time span is empty (zero length).
\r
977 * @return bool True is it's empty.
\r
981 return !$this->day && !$this->hour && !$this->minute && !$this->second;
\r
985 // {{{ setDefaultInputFormat()
\r
988 * Set the default input format.
\r
990 * @param mixed $format New default input format.
\r
992 * @return mixed Previous default input format.
\r
996 function setDefaultInputFormat($format)
\r
998 $old = $GLOBALS['_DATE_SPAN_INPUT_FORMAT'];
\r
999 $GLOBALS['_DATE_SPAN_INPUT_FORMAT'] = $format;
\r
1004 // {{{ getDefaultInputFormat()
\r
1007 * Get the default input format.
\r
1009 * @return mixed Default input format.
\r
1013 function getDefaultInputFormat()
\r
1015 return $GLOBALS['_DATE_SPAN_INPUT_FORMAT'];
\r
1019 // {{{ setDefaultFormat()
\r
1022 * Set the default format.
\r
1024 * @param mixed $format New default format.
\r
1026 * @return mixed Previous default format.
\r
1030 function setDefaultFormat($format)
\r
1032 $old = $GLOBALS['_DATE_SPAN_FORMAT'];
\r
1033 $GLOBALS['_DATE_SPAN_FORMAT'] = $format;
\r
1038 // {{{ getDefaultFormat()
\r
1041 * Get the default format.
\r
1043 * @return mixed Default format.
\r
1047 function getDefaultFormat()
\r
1049 return $GLOBALS['_DATE_SPAN_FORMAT'];
\r
1056 * Returns a copy of the object (workarround for PHP5 forward compatibility).
\r
1058 * @return object Date_Span Copy of the object.
\r
1060 function __clone() {
\r
1061 $c = get_class($this);
\r
1063 $s->day = $this->day;
\r
1064 $s->hour = $this->hour;
\r
1065 $s->minute = $this->minute;
\r
1066 $s->second = $this->second;
\r
1076 * Local variables:
\r
1079 * c-basic-offset: 4
\r
1080 * c-hanging-comment-ender-p: nil
\r