Date
[ class tree: Date ] [ index: Date ] [ all elements ]

File: Date.php

Source Location: /Date-1.5.0a4/Date.php

Classes:

Date
Generic date handling class for PEAR

Page Details:

Generic date handling class for PEAR

Handles time zones and changes from local standard to local Summer time (daylight-saving time) through the Date_TimeZone class. Supports several operations from Date_Calc on Date objects.

PHP versions 4 and 5

LICENSE:

Copyright (c) 1997-2008 Baba Buehler, Pierre-Alain Joye, Firman Wandayandi, C.A. Woodcock All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted under the terms of the BSD License.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Includes:

require_once('Date/Calc.php') [line 74]
Load Date_Calc
require_once('PEAR.php') [line 64]
require_once('Date/Span.php') [line 79]
Load Date_Span
require_once('Date/TimeZone.php') [line 69]
Load Date_TimeZone

DATE_CAPTURE_MICROTIME_BY_DEFAULT [line 93]

DATE_CAPTURE_MICROTIME_BY_DEFAULT = false
Whether to capture the micro-time (in microseconds) by default in calls to Date::setNow(). Note that this makes a call to gettimeofday(), which may not work on all systems.
  • Since: Constant available since Release 1.5.0

[ Top ]



DATE_CORRECTINVALIDTIME_DEFAULT [line 154]

DATE_CORRECTINVALIDTIME_DEFAULT = true
Whether to correct, by adding the local Summer time offset, the specified time if it falls in the 'skipped hour' (encountered when the clocks go forward).

N.B. if specified as 'false', and if a time zone that adjusts for Summer time is specified, then an object of this class will be set to a semi-invalid state if an invalid time is set. That is, an error will not be returned, unless the user then calls a function, directly or indirectly, that accesses the time part of the object. So, for example, if the user calls:

  1. $date_object->formatLikeSQL('HH.MI.SS');

or:

  1. $date_object->addSeconds(30);

an error will be returned if the time is invalid. However, if the user calls:

  1. $date_object->addDays(1);

for example, such that the time is no longer invalid, then the object will no longer be in this invalid state. This behaviour is intended to minimize unexpected errors when a user uses the class to do addition with days only, and does not intend to access the time.

Of course, this constant will be unused if the user chooses to work in UTC or a time zone without Summer time, in which case this situation will never arise.

This constant is set to 'true' by default for backwards-compatibility reasons, however, you are recommended to set it to 'false'. Note that the behaviour is not intended to match that of previous versions of the class in terms of ignoring the Summer time offset when making calculations which involve dates in both standard and Summer time - this was recognized as a bug - but in terms of returning a PEAR error object when the user sets the object to an invalid date (i.e. a time in the hour which is skipped when the clocks go forwards, which in Europe would be a time such as 01.30). Backwards compatibility here means that the behaviour is the same as it used to be, less the bug.

Note that this problem is not an issue for the user if any of these conditions are satisfied:

  1. the user uses a time zone that does not observe Summer time, e.g. UTC
  2. the user never accesses the time, that is, he never makes a call to Date::getHour() or Date::formatLikeStrftime() using format code '%H', for example, even if he sets the time to something invalid
  3. the user sets DATE_CORRECTINVALIDTIME_DEFAULT to true


[ Top ]



DATE_COUNT_LEAP_SECONDS [line 202]

DATE_COUNT_LEAP_SECONDS = false
Whether, by default, to accept times including leap seconds (i.e. '23.59.60') when setting the date/time, and whether to count leap seconds in the following functions:

This constant is set to 'false' by default for backwards-compatibility reasons, however, you are recommended to set it to 'true'.

Note that this constant does not affect Date::addSpan() and Date::subtractSpan() which will not count leap seconds in any case.

  • Since: Constant available since Release 1.5.0

[ Top ]



DATE_ERROR_INVALIDDATE [line 54]

DATE_ERROR_INVALIDDATE = 1

[ Top ]



DATE_ERROR_INVALIDDATEFORMAT [line 57]

DATE_ERROR_INVALIDDATEFORMAT = 4

[ Top ]



DATE_ERROR_INVALIDFORMATSTRING [line 58]

DATE_ERROR_INVALIDFORMATSTRING = 5

[ Top ]



DATE_ERROR_INVALIDTIME [line 55]

DATE_ERROR_INVALIDTIME = 2

[ Top ]



DATE_ERROR_INVALIDTIMEZONE [line 56]

DATE_ERROR_INVALIDTIMEZONE = 3

[ Top ]



DATE_FORMAT_ISO [line 218]

DATE_FORMAT_ISO = 1
"YYYY-MM-DD HH:MM:SS"

[ Top ]



DATE_FORMAT_ISO_BASIC [line 223]

DATE_FORMAT_ISO_BASIC = 2
"YYYYMMDDTHHMMSS(Z|(+/-)HHMM)?"

[ Top ]



DATE_FORMAT_ISO_EXTENDED [line 228]

DATE_FORMAT_ISO_EXTENDED = 3
"YYYY-MM-DDTHH:MM:SS(Z|(+/-)HH:MM)?"

[ Top ]



DATE_FORMAT_ISO_EXTENDED_MICROTIME [line 233]

DATE_FORMAT_ISO_EXTENDED_MICROTIME = 6
"YYYY-MM-DDTHH:MM:SS(.S*)?(Z|(+/-)HH:MM)?"

[ Top ]



DATE_FORMAT_METHOD [line 209]

DATE_FORMAT_METHOD = 'formatLikeStrftime'
Method to call when user invokes Date::format()
  • Since: Constant available since Release 1.5.1

[ Top ]



DATE_FORMAT_TIMESTAMP [line 238]

DATE_FORMAT_TIMESTAMP = 4
"YYYYMMDDHHMMSS"

[ Top ]



DATE_FORMAT_UNIXTIME [line 243]

DATE_FORMAT_UNIXTIME = 5
long int, seconds since the unix epoch

[ Top ]



DATE_VALIDATE_DATE_BY_DEFAULT [line 181]

DATE_VALIDATE_DATE_BY_DEFAULT = false
Whether to validate dates (i.e. day/month/year, ignoring the time) by disallowing invalid dates (e.g. 31st February) being set by the following functions:

If the constant is set to 'true', then the date will be checked (by default), and if invalid, an error will be returned with the Date object left unmodified.

This constant is set to 'false' by default for backwards-compatibility reasons, however, you are recommended to set it to 'true'.

Note that Date::setHour(), Date::setMinute(), Date::setSecond() and Date::setPartSecond() allow an invalid date/time to be set regardless of the value of this constant.


[ Top ]



Documentation generated on Mon, 11 Mar 2019 15:55:00 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.