Generic time span handling class for PEAR.
Located in /libraries/pear/Date/Span.php (line 71)
Constructor.
Creates the time span object calling the set() method.
Compares two time spans.
Compares two time spans. Suitable for use in sorting functions.
Set the time span from another time object.
Tells if time span is equal to $time.
Time span pretty printing (similar to Date::format()).
Formats the time span in the given format, similar to strftime() and Date::format().
Formatting options:
Days with time, same as "%D, %H:%M:%S".
- %C
Total days as a float number (2 days, 12 hours = 2.5 days).
- %d
Days as a decimal number.
- %D
Total hours as a float number (1 day, 2 hours, 30 minutes = 26.5 hours).
- %e
Total hours as a decimal number (1 day, 2 hours, 40 minutes = 26 hours).
- %E
Total minutes as a float number (2 minutes, 30 seconds = 2.5 minutes).
- %f
Total minutes as a decimal number (1 hour, 2 minutes, 40 seconds = 62 minutes).
- %F
Total seconds as a decimal number (2 minutes, 30 seconds = 90 seconds).
- %g
Hours as decimal number (0 to 23).
- %h
Hours as decimal number (00 to 23).
- %H
Hours as decimal number on 12-hour clock (1 to 12).
- %i
Hours as decimal number on 12-hour clock (01 to 12).
- %I
Minutes as a decimal number (0 to 59).
- %m
Minutes as a decimal number (00 to 59).
- %M
Newline character (\n).
- %n
Either 'am' or 'pm' depending on the time.
- %p
Either 'AM' or 'PM' depending on the time.
- %P
Time in am/pm notation, same as "%I:%M:%S %p".
- %r
Time in 24-hour notation, same as "%H:%M".
- %R
Seconds as a decimal number (0 to 59).
- %s
Seconds as a decimal number (00 to 59).
- %S
Tab character (\t).
- %t
Current time equivalent, same as "%H:%M:%S".
- %T
Literal '%'.
- %%
Get the default format.
Get the default input format.
Tells if this time span is greater than $time.
Tells if this time span is greater or equal than $time.
Tells if the time span is empty (zero length).
Tells if this time span is lower than $time.
Tells if this time span is lower or equal than $time.
Set the time span to a new value in a 'smart' way.
Sets the time span depending on the argument types, calling to the appropriate setFromXxx() method.
Set the default format.
Set the default input format.
Set the time span from an array.
Set the time span from an array. Any value can be a float (but it has no sense in seconds), for example array(23.5, 20, 0) is interpreted as 23 hours, .5*60 + 20 = 50 minutes and 0 seconds.
Set the span from the elapsed time between two dates.
Set the span from the elapsed time between two dates. The time span is allways positive, so the date's order is not important.
Set the time span from a total number of days.
Set the time span from a total number of hours.
Set the time span from a total number of minutes.
Set the time span from a total number of seconds.
Set the time span from a string based on an input format.
Set the time span from a string based on an input format. This is some like a mix of format() method and sscanf() PHP function. The error checking and validation of this function is very primitive, so you should be carefull when using it with unknown $time strings. With this method you are assigning day, hour, minute and second values, and the last values are used. This means that if you use something like setFromString('10, 20', '%H, %h') your time span would be 20 hours long. Allways remember that this method set all the values, so if you had a $time span 30 minutes long and you make $time->setFromString('20 hours', '%H hours'), $time span would be 20 hours long (and not 20 hours and 30 minutes). Input format options:
Days with time, same as "%D, %H:%M:%S".
- %C
Total days as a float number (2 days, 12 hours = 2.5 days).
- %d
Days as a decimal number.
- %D
Total hours as a float number (1 day, 2 hours, 30 minutes = 26.5 hours).
- %e
Total minutes as a float number (2 minutes, 30 seconds = 2.5 minutes).
- %f
Total seconds as a decimal number (2 minutes, 30 seconds = 90 seconds).
- %g
Hours as decimal number.
- %h
Hours as decimal number limited to 2 digits.
- %H
Minutes as a decimal number.
- %m
Minutes as a decimal number limited to 2 digits.
- %M
Newline character (\n).
- %n
Either 'am' or 'pm' depending on the time. If 'pm' is detected it adds 12 hours to the resulting time span (without any checks). This is case insensitive.
- %p
Time in am/pm notation, same as "%H:%M:%S %p".
- %r
Time in 24-hour notation, same as "%H:%M".
- %R
Seconds as a decimal number.
- %s
Seconds as a decimal number limited to 2 digits.
- %S
Tab character (\t).
- %t
Current time equivalent, same as "%H:%M:%S".
- %T
Literal '%'.
- %%
Subtracts a time span.
Subtracts a time span. If the time span to subtract is larger than the original, the result is zero (there's no sense in negative time spans).
Convert time span to days.
Convert time span to hours.
Convert time span to minutes.
Convert time span to seconds.
Returns a copy of the object (workarround for PHP5 forward compatibility).
Documentation generated on Fri, 11 Feb 2005 18:14:07 +0000 by phpDocumentor 1.3.0RC3