From: Diogo Cordeiro Date: Mon, 15 Jul 2019 00:40:09 +0000 (+0100) Subject: [CORE] Fixed some small issues with PEAR X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7d262ad50b399b55e3a25636456de8a3034de009;p=quix0rs-gnu-social.git [CORE] Fixed some small issues with PEAR --- diff --git a/Makefile b/Makefile index 6f45c1b83e..8d0a45153f 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ plugin_mo = $(patsubst %.po,%.mo,$(wildcard plugins/*/locale/*/LC_MESSAGES/*.po) translations : $(core_mo) $(plugin_mo) +upgrade : + php scripts/upgrade.php + clean : rm -f $(core_mo) $(plugin_mo) diff --git a/composer.json b/composer.json index e69a2f96f1..6806f1ae32 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "michelf/php-markdown": "^1.8.0", "openid/php-openid": "^2.3", "paragonie/constant_time_encoding": "^1.0.4", + "pear/console_getopt": "^1.4", "phpseclib/phpseclib": "dev-master#f815e43077da67d3dd5b4d18a45753f5b79c1ab9", "stomp-php/stomp-php": "^4.5.1" }, diff --git a/composer.lock b/composer.lock index 0ba40e438c..e7272a0303 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "443e1729de86d54a2d4e4707b15ad41d", + "content-hash": "f84a3a1654cf40103976cea8b2365b8c", "packages": [ { "name": "apereo/phpcas", @@ -682,6 +682,53 @@ ], "time": "2019-01-03T20:59:08+00:00" }, + { + "name": "pear/console_getopt", + "version": "v1.4.2", + "source": { + "type": "git", + "url": "https://github.com/pear/Console_Getopt.git", + "reference": "6c77aeb625b32bd752e89ee17972d103588b90c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Console_Getopt/zipball/6c77aeb625b32bd752e89ee17972d103588b90c0", + "reference": "6c77aeb625b32bd752e89ee17972d103588b90c0", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Console": "./" + } + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "./" + ], + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Greg Beaver", + "email": "cellog@php.net", + "role": "Helper" + }, + { + "name": "Andrei Zmievski", + "email": "andrei@php.net", + "role": "Lead" + }, + { + "name": "Stig Bakken", + "email": "stig@php.net", + "role": "Developer" + } + ], + "description": "More info available on: http://pear.php.net/package/Console_Getopt", + "time": "2019-02-06T16:52:33+00:00" + }, { "name": "phpseclib/phpseclib", "version": "dev-master", diff --git a/extlib/Console/Getopt.php b/extlib/Console/Getopt.php deleted file mode 100644 index d8abfc491d..0000000000 --- a/extlib/Console/Getopt.php +++ /dev/null @@ -1,366 +0,0 @@ - - * @license http://www.php.net/license/3_0.txt PHP 3.0 - * @version CVS: $Id: Getopt.php 306067 2010-12-08 00:13:31Z dufuz $ - * @link http://pear.php.net/package/Console_Getopt - */ - -require_once 'PEAR.php'; - -/** - * Command-line options parsing class. - * - * @category Console - * @package Console_Getopt - * @author Andrei Zmievski - * @license http://www.php.net/license/3_0.txt PHP 3.0 - * @link http://pear.php.net/package/Console_Getopt - */ -class Console_Getopt -{ - - /** - * Parses the command-line options. - * - * The first parameter to this function should be the list of command-line - * arguments without the leading reference to the running program. - * - * The second parameter is a string of allowed short options. Each of the - * option letters can be followed by a colon ':' to specify that the option - * requires an argument, or a double colon '::' to specify that the option - * takes an optional argument. - * - * The third argument is an optional array of allowed long options. The - * leading '--' should not be included in the option name. Options that - * require an argument should be followed by '=', and options that take an - * option argument should be followed by '=='. - * - * The return value is an array of two elements: the list of parsed - * options and the list of non-option command-line arguments. Each entry in - * the list of parsed options is a pair of elements - the first one - * specifies the option, and the second one specifies the option argument, - * if there was one. - * - * Long and short options can be mixed. - * - * Most of the semantics of this function are based on GNU getopt_long(). - * - * @param array $args an array of command-line arguments - * @param string $short_options specifies the list of allowed short options - * @param array $long_options specifies the list of allowed long options - * @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option - * - * @return array two-element array containing the list of parsed options and - * the non-option arguments - * @access public - */ - function getopt2($args, $short_options, $long_options = null, $skip_unknown = false) - { - return Console_Getopt::doGetopt(2, $args, $short_options, $long_options, $skip_unknown); - } - - /** - * This function expects $args to start with the script name (POSIX-style). - * Preserved for backwards compatibility. - * - * @param array $args an array of command-line arguments - * @param string $short_options specifies the list of allowed short options - * @param array $long_options specifies the list of allowed long options - * - * @see getopt2() - * @return array two-element array containing the list of parsed options and - * the non-option arguments - */ - function getopt($args, $short_options, $long_options = null, $skip_unknown = false) - { - return Console_Getopt::doGetopt(1, $args, $short_options, $long_options, $skip_unknown); - } - - /** - * The actual implementation of the argument parsing code. - * - * @param int $version Version to use - * @param array $args an array of command-line arguments - * @param string $short_options specifies the list of allowed short options - * @param array $long_options specifies the list of allowed long options - * @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option - * - * @return array - */ - function doGetopt($version, $args, $short_options, $long_options = null, $skip_unknown = false) - { - // in case you pass directly readPHPArgv() as the first arg - if (PEAR::isError($args)) { - return $args; - } - - if (empty($args)) { - return array(array(), array()); - } - - $non_opts = $opts = array(); - - settype($args, 'array'); - - if ($long_options) { - sort($long_options); - } - - /* - * Preserve backwards compatibility with callers that relied on - * erroneous POSIX fix. - */ - if ($version < 2) { - if (isset($args[0]{0}) && $args[0]{0} != '-') { - array_shift($args); - } - } - - reset($args); - while (list($i, $arg) = each($args)) { - /* The special element '--' means explicit end of - options. Treat the rest of the arguments as non-options - and end the loop. */ - if ($arg == '--') { - $non_opts = array_merge($non_opts, array_slice($args, $i + 1)); - break; - } - - if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) { - $non_opts = array_merge($non_opts, array_slice($args, $i)); - break; - } elseif (strlen($arg) > 1 && $arg{1} == '-') { - $error = Console_Getopt::_parseLongOption(substr($arg, 2), - $long_options, - $opts, - $args, - $skip_unknown); - if (PEAR::isError($error)) { - return $error; - } - } elseif ($arg == '-') { - // - is stdin - $non_opts = array_merge($non_opts, array_slice($args, $i)); - break; - } else { - $error = Console_Getopt::_parseShortOption(substr($arg, 1), - $short_options, - $opts, - $args, - $skip_unknown); - if (PEAR::isError($error)) { - return $error; - } - } - } - - return array($opts, $non_opts); - } - - /** - * Parse short option - * - * @param string $arg Argument - * @param string[] $short_options Available short options - * @param string[][] &$opts - * @param string[] &$args - * @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option - * - * @access private - * @return void - */ - function _parseShortOption($arg, $short_options, &$opts, &$args, $skip_unknown) - { - for ($i = 0; $i < strlen($arg); $i++) { - $opt = $arg{$i}; - $opt_arg = null; - - /* Try to find the short option in the specifier string. */ - if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':') { - if ($skip_unknown === true) { - break; - } - - $msg = "Console_Getopt: unrecognized option -- $opt"; - return PEAR::raiseError($msg); - } - - if (strlen($spec) > 1 && $spec{1} == ':') { - if (strlen($spec) > 2 && $spec{2} == ':') { - if ($i + 1 < strlen($arg)) { - /* Option takes an optional argument. Use the remainder of - the arg string if there is anything left. */ - $opts[] = array($opt, substr($arg, $i + 1)); - break; - } - } else { - /* Option requires an argument. Use the remainder of the arg - string if there is anything left. */ - if ($i + 1 < strlen($arg)) { - $opts[] = array($opt, substr($arg, $i + 1)); - break; - } else if (list(, $opt_arg) = each($args)) { - /* Else use the next argument. */; - if (Console_Getopt::_isShortOpt($opt_arg) - || Console_Getopt::_isLongOpt($opt_arg)) { - $msg = "option requires an argument --$opt"; - return PEAR::raiseError("Console_Getopt:" . $msg); - } - } else { - $msg = "option requires an argument --$opt"; - return PEAR::raiseError("Console_Getopt:" . $msg); - } - } - } - - $opts[] = array($opt, $opt_arg); - } - } - - /** - * Checks if an argument is a short option - * - * @param string $arg Argument to check - * - * @access private - * @return bool - */ - function _isShortOpt($arg) - { - return strlen($arg) == 2 && $arg[0] == '-' - && preg_match('/[a-zA-Z]/', $arg[1]); - } - - /** - * Checks if an argument is a long option - * - * @param string $arg Argument to check - * - * @access private - * @return bool - */ - function _isLongOpt($arg) - { - return strlen($arg) > 2 && $arg[0] == '-' && $arg[1] == '-' && - preg_match('/[a-zA-Z]+$/', substr($arg, 2)); - } - - /** - * Parse long option - * - * @param string $arg Argument - * @param string[] $long_options Available long options - * @param string[][] &$opts - * @param string[] &$args - * - * @access private - * @return void|PEAR_Error - */ - function _parseLongOption($arg, $long_options, &$opts, &$args, $skip_unknown) - { - @list($opt, $opt_arg) = explode('=', $arg, 2); - - $opt_len = strlen($opt); - - for ($i = 0; $i < count($long_options); $i++) { - $long_opt = $long_options[$i]; - $opt_start = substr($long_opt, 0, $opt_len); - - $long_opt_name = str_replace('=', '', $long_opt); - - /* Option doesn't match. Go on to the next one. */ - if ($long_opt_name != $opt) { - continue; - } - - $opt_rest = substr($long_opt, $opt_len); - - /* Check that the options uniquely matches one of the allowed - options. */ - if ($i + 1 < count($long_options)) { - $next_option_rest = substr($long_options[$i + 1], $opt_len); - } else { - $next_option_rest = ''; - } - - if ($opt_rest != '' && $opt{0} != '=' && - $i + 1 < count($long_options) && - $opt == substr($long_options[$i+1], 0, $opt_len) && - $next_option_rest != '' && - $next_option_rest{0} != '=') { - - $msg = "Console_Getopt: option --$opt is ambiguous"; - return PEAR::raiseError($msg); - } - - if (substr($long_opt, -1) == '=') { - if (substr($long_opt, -2) != '==') { - /* Long option requires an argument. - Take the next argument if one wasn't specified. */; - if (!strlen($opt_arg) && !(list(, $opt_arg) = each($args))) { - $msg = "Console_Getopt: option requires an argument --$opt"; - return PEAR::raiseError($msg); - } - - if (Console_Getopt::_isShortOpt($opt_arg) - || Console_Getopt::_isLongOpt($opt_arg)) { - $msg = "Console_Getopt: option requires an argument --$opt"; - return PEAR::raiseError($msg); - } - } - } else if ($opt_arg) { - $msg = "Console_Getopt: option --$opt doesn't allow an argument"; - return PEAR::raiseError($msg); - } - - $opts[] = array('--' . $opt, $opt_arg); - return; - } - - if ($skip_unknown === true) { - return; - } - - return PEAR::raiseError("Console_Getopt: unrecognized option --$opt"); - } - - /** - * Safely read the $argv PHP array across different PHP configurations. - * Will take care on register_globals and register_argc_argv ini directives - * - * @access public - * @return mixed the $argv PHP array or PEAR error if not registered - */ - function readPHPArgv() - { - global $argv; - if (!is_array($argv)) { - if (!@is_array($_SERVER['argv'])) { - if (!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) { - $msg = "Could not read cmd args (register_argc_argv=Off?)"; - return PEAR::raiseError("Console_Getopt: " . $msg); - } - return $GLOBALS['HTTP_SERVER_VARS']['argv']; - } - return $_SERVER['argv']; - } - return $argv; - } - -} \ No newline at end of file diff --git a/extlib/Date.php b/extlib/Date.php deleted file mode 100644 index 71cbe64990..0000000000 --- a/extlib/Date.php +++ /dev/null @@ -1,6672 +0,0 @@ - - * @author Pierre-Alain Joye - * @author Firman Wandayandi - * @author C.A. Woodcock - * @copyright 1997-2007 Baba Buehler, Pierre-Alain Joye, Firman Wandayandi, C.A. Woodcock - * @license http://www.opensource.org/licenses/bsd-license.php - * BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/Date - */ - - -// }}} -// {{{ Error constants - -define('DATE_ERROR_INVALIDDATE', 1); -define('DATE_ERROR_INVALIDTIME', 2); -define('DATE_ERROR_INVALIDTIMEZONE', 3); -define('DATE_ERROR_INVALIDDATEFORMAT', 4); -define('DATE_ERROR_INVALIDFORMATSTRING', 5); - - -// }}} -// {{{ Includes - -require_once 'PEAR.php'; - -/** - * Load Date_TimeZone - */ -require_once 'Date/TimeZone.php'; - -/** - * Load Date_Calc - */ -require_once 'Date/Calc.php'; - -/** - * Load Date_Span - */ -require_once 'Date/Span.php'; - - -// }}} -// {{{ General constants - -/** - * Whether to capture the micro-time (in microseconds) by default - * in calls to {@link Date::setNow()}. Note that this makes a call to - * {@link http://www.php.net/gettimeofday gettimeofday()}, which may - * not work on all systems. - * - * @since Constant available since Release 1.5.0 - */ -define('DATE_CAPTURE_MICROTIME_BY_DEFAULT', false); - -/** - * 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: - * - * $date_object->formatLikeSQL('HH.MI.SS'); - * - * or: - * - * $date_object->addSeconds(30); - * - * an error will be returned if the time is invalid. However, - * if the user calls: - * - * $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. - *
  3. the user never accesses the time, that is, he never makes a call to - * {@link Date::getHour()} or {@link Date::formatLikeStrftime()} using - * format code '%H', for example, even if he sets the time to - * something invalid
  4. - *
  5. the user sets DATE_CORRECTINVALIDTIME_DEFAULT to true
  6. - *
- * - * @since Constant available since Release 1.5.0 - * @see Date::isValidTime(), DATE_VALIDATE_DATE_BY_DEFAULT - */ -define('DATE_CORRECTINVALIDTIME_DEFAULT', true); - -/** - * 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: - * - * - {@link Date::setYear()} - * - {@link Date::setMonth()} - * - {@link Date::setDay()} - * - * 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 {@link Date::setHour()}, {@link Date::setMinute()}, - * {@link Date::setSecond()} and {@link Date::setPartSecond()} - * allow an invalid date/time to be set regardless of the value of this - * constant. - * - * @see Date::isValidDate(), Date::isValidTime(), Date::isNull(), - * DATE_CORRECTINVALIDTIME_DEFAULT - * @since Constant available since Release 1.5.0 - */ -define('DATE_VALIDATE_DATE_BY_DEFAULT', 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: - * - * - {@link Date::addSeconds()} - * - {@link Date::subtractSeconds()} - * - {@link Date_Calc::addSeconds()} - * - {@link Date::round()} - * - {@link Date::roundSeconds()} - * - * 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 {@link Date::addSpan()} and - * {@link Date::subtractSpan()} which will not count leap seconds in any case. - * - * @since Constant available since Release 1.5.0 - */ -define('DATE_COUNT_LEAP_SECONDS', false); - -/** - * Method to call when user invokes {@link Date::format()} - * - * @since Constant available since Release 1.5.1 - */ -define('DATE_FORMAT_METHOD', 'formatLikeStrftime'); - - -// }}} -// {{{ Output format constants (used in {@link Date::getDate()}) - -/** - * "YYYY-MM-DD HH:MM:SS" - */ -define('DATE_FORMAT_ISO', 1); - -/** - * "YYYYMMDDTHHMMSS(Z|(+/-)HHMM)?" - */ -define('DATE_FORMAT_ISO_BASIC', 2); - -/** - * "YYYY-MM-DDTHH:MM:SS(Z|(+/-)HH:MM)?" - */ -define('DATE_FORMAT_ISO_EXTENDED', 3); - -/** - * "YYYY-MM-DDTHH:MM:SS(.S*)?(Z|(+/-)HH:MM)?" - */ -define('DATE_FORMAT_ISO_EXTENDED_MICROTIME', 6); - -/** - * "YYYYMMDDHHMMSS" - */ -define('DATE_FORMAT_TIMESTAMP', 4); - -/** - * long int, seconds since the unix epoch - */ -define('DATE_FORMAT_UNIXTIME', 5); - - -// }}} -// {{{ Class: Date - -/** - * Generic date handling class for PEAR - * - * Supports time zones with the Date_TimeZone class. Supports several - * operations from Date_Calc on Date objects. - * - * Note to developers: the class stores the local time and date in the - * local standard time. That is, it does not store the time as the - * local Summer time when and if the time zone is in Summer time. It - * is much easier to store local standard time and remember to offset - * it when the user requests it. - * - * @category Date and Time - * @package Date - * @author Baba Buehler - * @author Pierre-Alain Joye - * @author Firman Wandayandi - * @author C.A. Woodcock - * @copyright 1997-2007 Baba Buehler, Pierre-Alain Joye, Firman Wandayandi, C.A. Woodcock - * @license http://www.opensource.org/licenses/bsd-license.php - * BSD License - * @version Release: 1.5.0a1 - * @link http://pear.php.net/package/Date - */ -class Date -{ - - // {{{ Properties - - /** - * The year - * - * @var int - * @access private - * @since Property available since Release 1.0 - */ - public $year; - - /** - * The month - * - * @var int - * @access private - * @since Property available since Release 1.0 - */ - public $month; - - /** - * The day - * - * @var int - * @access private - * @since Property available since Release 1.0 - */ - public $day; - - /** - * The hour - * - * @var int - * @access private - * @since Property available since Release 1.0 - */ - public $hour; - - /** - * The minute - * - * @var int - * @access private - * @since Property available since Release 1.0 - */ - public $minute; - - /** - * The second - * - * @var int - * @access private - * @since Property available since Release 1.0 - */ - public $second; - - /** - * The parts of a second - * - * @var float - * @access private - * @since Property available since Release 1.4.3 - */ - public $partsecond; - - /** - * The year in local standard time - * - * @var int - * @access private - * @since Property available since Release 1.5.0 - */ - public $on_standardyear; - - /** - * The month in local standard time - * - * @var int - * @access private - * @since Property available since Release 1.5.0 - */ - public $on_standardmonth; - - /** - * The day in local standard time - * - * @var int - * @access private - * @since Property available since Release 1.5.0 - */ - public $on_standardday; - - /** - * The hour in local standard time - * - * @var int - * @access private - * @since Property available since Release 1.5.0 - */ - public $on_standardhour; - - /** - * The minute in local standard time - * - * @var int - * @access private - * @since Property available since Release 1.5.0 - */ - public $on_standardminute; - - /** - * The second in local standard time - * - * @var int - * @access private - * @since Property available since Release 1.5.0 - */ - public $on_standardsecond; - - /** - * The part-second in local standard time - * - * @var float - * @access private - * @since Property available since Release 1.5.0 - */ - public $on_standardpartsecond; - - /** - * Whether the object should accept and count leap seconds - * - * @var bool - * @access private - * @since Property available since Release 1.5.0 - */ - public $ob_countleapseconds; - - /** - * Whether the time is valid as a local time (an invalid time - * is one that lies in the 'skipped hour' at the point that - * the clocks go forward) - * - * @var bool - * @access private - * @see Date::isValidTime() - * @since Property available since Release 1.5.0 - */ - public $ob_invalidtime = null; - - /** - * Date_TimeZone object for this date - * - * @var object Date_TimeZone object - * @access private - * @since Property available since Release 1.0 - */ - public $tz; - - /** - * Defines the default weekday abbreviation length - * - * Formerly used by {@link Date::formatLikeStrftime()}, but now - * redundant - the abbreviation for the current locale of the machine - * is used. - * - * @var int - * @access private - * @since Property available since Release 1.4.4 - */ - public $getWeekdayAbbrnameLength = 3; - - - // }}} - // {{{ Constructor - - /** - * Constructor - * - * Creates a new Date Object initialized to the current date/time in the - * system-default timezone by default. A date optionally - * passed in may be in the ISO 8601, TIMESTAMP or UNIXTIME format, - * or another Date object. If no date is passed, the current date/time - * is used. - * - * If a date is passed and an exception is returned by {@link Date::setDate()} - * there is nothing that this function can do, so for this reason, it - * is advisable to pass no parameter and to make a separate call to - * Date::setDate(). A date/time should only be passed if known to be a - * valid ISO 8601 string or a valid Unix timestamp. - * - * @param mixed $date optional ISO 8601 date/time to initialize; - * or, a Unix time stamp - * @param bool $pb_countleapseconds whether to count leap seconds - * (defaults to - * {@link DATE_COUNT_LEAP_SECONDS}) - * - * @return void - * @access public - * @see Date::setDate() - */ - public function Date( - $date = null, - $pb_countleapseconds = DATE_COUNT_LEAP_SECONDS - ) - { - $this->ob_countleapseconds = $pb_countleapseconds; - - if (is_a($date, 'Date')) { - $this->copy($date); - } else { - if (!is_null($date)) { - // 'setDate()' expects a time zone to be already set: - // - $this->_setTZToDefault(); - $this->setDate($date); - } else { - $this->setNow(); - } - } - } - - - // }}} - // {{{ copy() - - /** - * Copy values from another Date object - * - * Makes this Date a copy of another Date object. This is a - * PHP4-compatible implementation of {@link Date::__clone()} in PHP5. - * - * @param object $date Date object to copy - * - * @return void - * @access public - */ - public function copy($date) - { - $this->year = $date->year; - $this->month = $date->month; - $this->day = $date->day; - $this->hour = $date->hour; - $this->minute = $date->minute; - $this->second = $date->second; - $this->partsecond = $date->partsecond; - - $this->on_standardyear = $date->on_standardyear; - $this->on_standardmonth = $date->on_standardmonth; - $this->on_standardday = $date->on_standardday; - $this->on_standardhour = $date->on_standardhour; - $this->on_standardminute = $date->on_standardminute; - $this->on_standardsecond = $date->on_standardsecond; - $this->on_standardpartsecond = $date->on_standardpartsecond; - - $this->ob_countleapseconds = $date->ob_countleapseconds; - $this->ob_invalidtime = $date->ob_invalidtime; - - $this->tz = new Date_TimeZone($date->getTZID()); - - $this->getWeekdayAbbrnameLength = $date->getWeekdayAbbrnameLength; - } - - - // }}} - // {{{ __clone() - - /** - * Copy values from another Date object - * - * Makes this Date a copy of another Date object. For PHP5 - * only. - * - * @return void - * @access public - * @see Date::copy() - */ - public function __clone() - { - // This line of code would be preferable, but will only - // compile in PHP5: - // - // $this->tz = clone $this->tz; - - $this->tz = new Date_TimeZone($this->getTZID()); - } - - - // }}} - // {{{ isNull() - - /** - * Returns whether the object is null (i.e. no date has been set) - * - * If the object is set to an invalid date, then this function will - * still return 'false'. To check whether the date is valid use - * either {@link Date::isValidDate()} (to check the day/month/year - * part of the object only) or {@link Date::isValidTime()} (to check - * the time, in addition to the day/month/year part). - * - * @return bool - * @access public - * @see Date::setDate(), Date::isValidDate(), Date::isValidTime() - * @since Method available since Release 1.5.0 - */ - public function isNull() - { - return is_null($this->year); - } - - - // }}} - // {{{ isValidDate() - - /** - * Returns whether the date (i.e. day/month/year) is valid - * - * It is not possible to set the object to an invalid date using - * {@link Date::setDate()}, but it is possible to do so using the - * following functions: - * - * - {@link Date::setYear()} - * - {@link Date::setMonth()} - * - {@link Date::setDay()} - * - * However you can prevent this possibility (by default) by setting - * {@link DATE_VALIDATE_DATE_BY_DEFAULT} to 'true', in which case - * these three functions will return an error if they specify an - * invalid date, and the object will be unmodified. - * - * Note that this function only checks the day/month/year part of - * the object. Even if this is valid, it is still possible for the - * time to be invalid (see {@link DATE_CORRECTINVALIDTIME_DEFAULT}). - * To check the time as well, use {@link Date::isValidTime()}. - * - * @return bool - * @access public - * @see Date::setDate(), Date::isNull(), Date::isValidTime() - * @since Method available since Release 1.5.0 - */ - public function isValidDate() - { - return - !Date::isNull() && - Date_Calc::isValidDate($this->year, $this->month, $this->day); - } - - - // }}} - // {{{ setDate() - - /** - * Sets the date/time of the object based on the input date and format - * - * Accepts a string in three possible formats, and in this order of - * precedence: - * - * - ISO 8601 date (see {@link http://en.wikipedia.org/wiki/ISO_8601}) - * - Time-Stamp (i.e. 'YYYYMMDDHHMMSS') - * - Unix time-stamp (see {@link http://en.wikipedia.org/wiki/Unix_time}) - * - * Note that if you want to pass a Unix time-stamp then you need to set - * the $format parameter to {@link DATE_FORMAT_UNIXTIME}, or else use the - * method {@link Date::setFromTime()}. - * - * The input string should be a date/time representation in one of the - * following general formats: - * - * - T - * - (non-ISO-standard) - * - (non-ISO-standard) - * - T i.e. without optional representation - * - - * - - * - i.e. without optional