Class Horde_Date

Description

Located in /Date.php (line 54)


	
			
Class Constant Summary
Variable Summary
 static array $_corrections
 static string $_defaultSpecs
 static string $_supportedSpecs
 integer $_hour
 integer $_mday
 integer $_min
 integer $_month
 integer $_sec
 string $_timezone
 integer $_year
Method Summary
 static Horde_Date fromDays (int $days, string $format)
 static integer weeksInYear (integer $year)
 Horde_Date __construct ([ $date = null], [ $timezone = null])
 void add ( $factor)
 boolean after (mixed $other)
 boolean before (mixed $other)
 integer compareDate (mixed $other)
 integer compareDateTime (mixed $other)
 integer compareTime (mixed $other)
 integer datestamp ()
 string dateString ()
 integer dayOfWeek ()
 integer dayOfYear ()
 integer diff (Horde_Date $other)
 boolean equals (mixed $other)
 string format (string $format)
 boolean isValid ()
 void setDefaultFormat (string $format)
 void setNthWeekday (integer $weekday, [integer $nth = 1])
 Horde_Date setTimezone (string $timezone)
 string strftime ( $format)
 void sub ( $factor)
 integer timestamp ()
 DateTime toDateTime ()
 integer toDays ()
 string toiCalendar ([boolean $floating = false])
 string toJson ()
 string tzOffset ([boolean $colon = true])
 integer weekOfMonth ()
 integer weekOfYear ()
 void _correct ([integer $mask = self::MASK_ALLPARTS], [integer $down = false])
 void _correctMonth ([integer $down = false])
 void _initializeFromArgs ( $args)
 void _initializeFromArray ( $date)
 void _initializeFromObject ( $date)
 void _initializeTimezone ( $timezone)
 string _strftime ( $format)
 integer __get (string $name)
 boolen __isset (string $name)
 void __set (string $name, integer $value)
 string __toString ()
Variables
static array $_corrections = array(
'year' => self::MASK_YEAR,
'month' => self::MASK_MONTH,
'mday' => self::MASK_DAY,
'hour' => self::MASK_HOUR,
'min' => self::MASK_MINUTE,
'sec' => self::MASK_SECOND,
)
(line 161)

Map of required correction masks.

static string $_defaultSpecs = '%CdDeHImMnRStTyY' (line 146)

Default specs that are always supported.

  • access: protected
static string $_supportedSpecs = '' (line 152)

Internally supported strftime() specifiers.

  • access: protected
string $_defaultFormat = self::DATE_DEFAULT (line 140)

Default format for __toString()

  • access: protected
mixed $_formatCache = array() (line 170)
  • access: protected
integer $_hour = 0 (line 112)

Hour

  • access: protected
integer $_mday (line 105)

Day

  • access: protected
integer $_min = 0 (line 119)

Minute

  • access: protected
integer $_month (line 98)

Month

  • access: protected
integer $_sec = 0 (line 126)

Second

  • access: protected
string $_timezone (line 133)

String representation of the date's timezone.

  • access: protected
integer $_year (line 91)

Year

  • access: protected
Methods
static fromDays (line 385)

Converts number of days since 24th November, 4714 B.C. (in the proleptic Gregorian calendar, which is year -4713 using 'Astronomical' year numbering) to Gregorian calendar date.

Returned date belongs to the proleptic Gregorian calendar, using 'Astronomical' year numbering.

The algorithm is valid for all years (positive and negative), and also for years preceding 4714 B.C. (i.e. for negative 'Julian Days'), and so the only limitation is platform-dependent (for 32-bit systems the maximum year would be something like about 1,465,190 A.D.).

N.B. Monday, 24th November, 4714 B.C. is Julian Day '0'.

Algorithm is from PEAR::Date_Calc

static Horde_Date fromDays (int $days, string $format)
  • int $days: the number of days since 24th November, 4714 B.C.
  • string $format: the string indicating how to format the output
static weeksInYear (line 608)

Returns the number of weeks in the given year (52 or 53).

  • return: The number of weeks in $year.
  • access: public
static integer weeksInYear (integer $year)
  • integer $year: The year to count the number of weeks in.
Constructor __construct (line 190)

Builds a new date object. If $date contains date parts, use them to initialize the object.

Recognized formats:

  • arrays with keys 'year', 'month', 'mday', 'day' 'hour', 'min', 'minute', 'sec'
  • objects with properties 'year', 'month', 'mday', 'hour', 'min', 'sec'
  • yyyy-mm-dd hh:mm:ss
  • yyyymmddhhmmss
  • yyyymmddThhmmssZ
  • yyyymmdd (might conflict with unix timestamps between 31 Oct 1966 and 03 Mar 1973)
  • unix timestamps
  • anything parsed by strtotime()/DateTime.

  • throws: Horde_Date_Exception
  • access: public
Horde_Date __construct ([ $date = null], [ $timezone = null])
  • $date
  • $timezone
add (line 484)

Adds a number of seconds or units to this date, returning a new Date object.

  • access: public
void add ( $factor)
  • $factor
after (line 686)

Returns whether this date is after the other.

  • return: True if this date is after the other.
  • access: public
boolean after (mixed $other)
  • mixed $other: The date to compare to.
before (line 698)

Returns whether this date is before the other.

  • return: True if this date is before the other.
  • access: public
boolean before (mixed $other)
  • mixed $other: The date to compare to.
compareDate (line 663)

Compares this date to another date object to see which one is greater (later). Assumes that the dates are in the same timezone.

  • return: == 0 if they are on the same date >= 1 if $this is greater (later) <= -1 if $other is greater (later)
  • access: public
integer compareDate (mixed $other)
  • mixed $other: The date to compare to.
compareDateTime (line 753)

Compares this to another date object, including times, to see which one is greater (later). Assumes that the dates are in the same timezone.

  • return: == 0 if they are equal >= 1 if $this is greater (later) <= -1 if $other is greater (later)
  • access: public
integer compareDateTime (mixed $other)
  • mixed $other: The date to compare to.
compareTime (line 726)

Compares this to another date object by time, to see which one is greater (later). Assumes that the dates are in the same timezone.

  • return: == 0 if they are at the same time >= 1 if $this is greater (later) <= -1 if $other is greater (later)
  • access: public
integer compareTime (mixed $other)
  • mixed $other: The date to compare to.
datestamp (line 809)

Returns the unix timestamp representation of this date, 12:00am.

  • return: A unix timestamp.
  • access: public
integer datestamp ()
dateString (line 823)

Formats date and time to be passed around as a short url parameter.

  • return: Date and time.
  • access: public
string dateString ()
dayOfWeek (line 552)

Returns the day of the week (0 = Sunday, 6 = Saturday) of this date.

  • return: The day of the week.
  • access: public
integer dayOfWeek ()
dayOfYear (line 576)

Returns the day number of the year (1 to 365/366).

  • return: The day of the year.
  • access: public
integer dayOfYear ()
diff (line 773)

Returns number of days between this date and another.

  • return: The absolute number of days between the two dates.
  • access: public
integer diff (Horde_Date $other)
equals (line 710)

Returns whether this date is the same like the other.

  • return: True if this date is the same like the other.
  • access: public
boolean equals (mixed $other)
  • mixed $other: The date to compare to.
format (line 866)

Formats time using the specifiers available in date() or in the DateTime class' format() method.

To format in languages other than English, use strftime() instead.

  • return: Formatted time.
  • access: public
string format (string $format)
  • string $format
isValid (line 647)

Is the date currently represented by this object a valid date?

  • return: Validity, counting leap years, etc.
  • access: public
boolean isValid ()
setDefaultFormat (line 542)

Sets the default date format used in __toString()

  • access: public
void setDefaultFormat (string $format)
  • string $format
setNthWeekday (line 624)

Sets the date of this object to the $nth weekday of $weekday.

  • access: public
void setNthWeekday (integer $weekday, [integer $nth = 1])
  • integer $weekday: The day of the week (0 = Sunday, etc).
  • integer $nth: The $nth $weekday to set to (defaults to 1).
setTimezone (line 522)

Converts this object to a different timezone.

  • return: This object.
  • access: public
Horde_Date setTimezone (string $timezone)
  • string $timezone: The new timezone.
strftime (line 879)

Formats date and time using strftime() format.

  • return: formatted date and time.
  • access: public
string strftime ( $format)
  • $format
sub (line 502)

Subtracts a number of seconds or units from this date, returning a new Horde_Date object.

  • access: public
void sub ( $factor)
  • $factor
timestamp (line 795)

Returns the unix timestamp representation of this date.

  • return: A unix timestamp.
  • access: public
integer timestamp ()
toDateTime (line 284)

Returns a DateTime object representing this object.

  • access: public
DateTime toDateTime ()
toDays (line 317)

Converts a date in the proleptic Gregorian calendar to the no of days since 24th November, 4714 B.C.

Returns the no of days since Monday, 24th November, 4714 B.C. in the proleptic Gregorian calendar (which is 24th November, -4713 using 'Astronomical' year numbering, and 1st January, 4713 B.C. in the proleptic Julian calendar). This is also the first day of the 'Julian Period' proposed by Joseph Scaliger in 1583, and the number of days since this date is known as the 'Julian Day'. (It is not directly to do with the Julian calendar, although this is where the name is derived from.)

The algorithm is valid for all years (positive and negative), and also for years preceding 4714 B.C.

Algorithm is from PEAR::Date_Calc

integer toDays ()
toiCalendar (line 846)

Formats date and time to the RFC 2445 iCalendar DATE-TIME format.

  • return: Date and time.
  • access: public
string toiCalendar ([boolean $floating = false])
  • boolean $floating: Whether to return a floating date-time (without time zone information).
toJson (line 833)

Formats date and time to the ISO format used by JSON.

  • return: Date and time.
  • access: public
string toJson ()
tzOffset (line 785)

Returns the time offset for local time zone.

  • return: Timezone offset as a string in the format +HH:MM.
  • access: public
string tzOffset ([boolean $colon = true])
  • boolean $colon: Place a colon between hours and minutes?
weekOfMonth (line 586)

Returns the week of the month.

  • return: The week number.
  • access: public
integer weekOfMonth ()
weekOfYear (line 596)

Returns the week of the year, first Monday is first day of first week.

  • return: The week number.
  • access: public
integer weekOfYear ()
_correct (line 947)

Corrects any over- or underflows in any of the date's members.

  • access: protected
void _correct ([integer $mask = self::MASK_ALLPARTS], [integer $down = false])
  • integer $mask: We may not want to correct some overflows.
  • integer $down: Whether to correct the date up or down.
_correctMonth (line 1022)

Corrects the current month.

This cannot be done in _correct() because that would also trigger a correction of the day, which would result in an infinite loop.

  • access: protected
void _correctMonth ([integer $down = false])
  • integer $down: Whether to correct the date up or down.
_initializeFromArgs (line 1035)

Handles args in order: year month day hour min sec tz

  • access: protected
void _initializeFromArgs ( $args)
  • $args
_initializeFromArray (line 1048)
  • access: protected
void _initializeFromArray ( $date)
  • $date
_initializeFromObject (line 1079)
  • access: protected
void _initializeFromObject ( $date)
  • $date
_initializeTimezone (line 1104)
  • access: protected
void _initializeTimezone ( $timezone)
  • $timezone
_strftime (line 893)

Formats date and time using a limited set of the strftime() format.

  • return: formatted date and time.
  • access: protected
string _strftime ( $format)
  • $format
__get (line 425)

Getter for the date and time properties.

  • return: The property value, or null if not set.
  • access: public
integer __get (string $name)
  • string $name: One of 'year', 'month', 'mday', 'hour', 'min' or 'sec'.
__isset (line 470)

Returns whether a date or time property exists.

  • return: True if the property exists and is set.
  • access: public
boolen __isset (string $name)
  • string $name: One of 'year', 'month', 'mday', 'hour', 'min' or 'sec'.
__set (line 441)

Setter for the date and time properties.

  • access: public
void __set (string $name, integer $value)
  • string $name: One of 'year', 'month', 'mday', 'hour', 'min' or 'sec'.
  • integer $value: The property value.
__toString (line 270)

Returns a simple string representation of the date object

  • return: This object converted to a string.
  • access: public
string __toString ()
Class Constants
DATE_DEFAULT = 'Y-m-d H:i:s' (line 83)
DATE_FRIDAY = 5 (line 61)
DATE_JSON = 'Y-m-d\TH:i:s' (line 84)
DATE_MONDAY = 1 (line 57)
DATE_SATURDAY = 6 (line 62)
DATE_SUNDAY = 0 (line 56)
DATE_THURSDAY = 4 (line 60)
DATE_TUESDAY = 2 (line 58)
DATE_WEDNESDAY = 3 (line 59)
MASK_ALLDAYS = 127 (line 73)
MASK_ALLPARTS = 63 (line 81)
MASK_DAY = 8 (line 78)
MASK_FRIDAY = 32 (line 69)
MASK_HOUR = 4 (line 77)
MASK_MINUTE = 2 (line 76)
MASK_MONDAY = 2 (line 65)
MASK_MONTH = 16 (line 79)
MASK_SATURDAY = 64 (line 70)
MASK_SECOND = 1 (line 75)
MASK_SUNDAY = 1 (line 64)
MASK_THURSDAY = 16 (line 68)
MASK_TUESDAY = 4 (line 66)
MASK_WEDNESDAY = 8 (line 67)
MASK_WEEKDAYS = 62 (line 71)
MASK_WEEKEND = 65 (line 72)
MASK_YEAR = 32 (line 80)

Documentation generated on Sun, 13 May 2012 03:29:50 +0000 by phpDocumentor 1.4.3