当前位置: 首页>>代码示例>>PHP>>正文


PHP DateUtil::addMonths方法代码示例

本文整理汇总了PHP中DateUtil::addMonths方法的典型用法代码示例。如果您正苦于以下问题:PHP DateUtil::addMonths方法的具体用法?PHP DateUtil::addMonths怎么用?PHP DateUtil::addMonths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateUtil的用法示例。


在下文中一共展示了DateUtil::addMonths方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: entryFrom

 /**
  * Parse raw listing entry.
  *
  * @param   string raw a single line
  * @param   peer.ftp.FtpConnection connection
  * @param   string base default "/"
  * @param   util.Date ref default NULL
  * @return  peer.ftp.FtpEntry
  */
 public function entryFrom($raw, FtpConnection $conn = NULL, $base = '/', Date $ref = NULL)
 {
     sscanf($raw, '%s %d %s %s %d %s %d %[^ ] %[^$]', $permissions, $numlinks, $user, $group, $size, $month, $day, $date, $filename);
     // Only qualify filenames if they appear unqualified in the listing
     if ('/' !== $filename[0]) {
         $filename = $base . $filename;
     }
     // Create a directory or an entry
     if ('d' === $permissions[0]) {
         $e = new FtpDir($filename, $conn);
     } else {
         $e = new FtpFile($filename, $conn);
     }
     // If the entry contains a timestamp, the year is omitted, "Apr 4 20:16"
     // instead of "Apr 4 2009". This compact format is used when the file
     // time is within six months* from the current date, in either direction!
     //
     // *] #define SIXMONTHS       ((365 / 2) * 86400) := 15724800
     //    See http://svn.freebsd.org/base/projects/releng_7_xen/bin/ls/print.c
     if (strstr($date, ':')) {
         $ref || ($ref = Date::now());
         $d = new Date($month . ' ' . $day . ' ' . $ref->getYear() . ' ' . $date);
         if ($d->getTime() - $ref->getTime() > 15724800) {
             $d = DateUtil::addMonths($d, -12);
         }
     } else {
         $d = new Date($month . ' ' . $day . ' ' . $date);
     }
     try {
         $e->setPermissions(substr($permissions, 1));
         $e->setNumlinks($numlinks);
         $e->setUser($user);
         $e->setGroup($group);
         $e->setSize($size);
         $e->setDate($d);
     } catch (IllegalArgumentException $e) {
         throw new FormatException('Cannot parse "' . $raw . '": ' . $e->getMessage());
     }
     return $e;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:49,代码来源:DefaultFtpListParser.class.php

示例2: onList

 /**
  * LIST: This command causes a list of file names and file details 
  * to be sent from the FTP site to the client.
  *
  * @param   peer.Socket socket
  * @param   string params
  */
 public function onList($socket, $params)
 {
     if (!($dataSocket = $this->openDatasock($socket))) {
         return;
     }
     // Split options from arguments
     if (substr($params, 0, 1) === '-') {
         list($options, $params) = explode(' ', substr($params, 1), 2);
         $this->cat && $this->cat->debug('+++ Options:', $options);
     } else {
         $options = '';
     }
     if (!($entry = $this->storage->lookup($socket->hashCode(), $params))) {
         $this->answer($socket, 550, $params . ': No such file or directory');
         $dataSocket->close();
         delete($dataSocket);
         $this->cat && $this->cat->debug($socket, $this->datasock[$socket->hashCode()]);
         return;
     }
     // Invoke interceptor
     if (!$this->checkInterceptors($socket, $entry, 'onRead')) {
         $dataSocket->close();
         return;
     }
     $this->answer($socket, 150, sprintf('Opening %s mode data connection for filelist', $this->sessions[$socket->hashCode()]->typeName()));
     // If a collection was specified, list its elements, otherwise,
     // list the single element
     if ($entry instanceof StorageCollection && !strstr($options, 'd')) {
         $elements = $entry->elements();
     } else {
         $elements = array($entry);
     }
     $before6Months = DateUtil::addMonths(Date::now(), -6)->getTime();
     for ($i = 0, $s = sizeof($elements); $i < $s; $i++) {
         $buf = sprintf('%s  %2d %s  %s  %8d %s %s', $this->permissionString($elements[$i]->getPermissions()), $elements[$i]->numLinks(), $elements[$i]->getOwner(), $elements[$i]->getGroup(), $elements[$i]->getSize(), date($elements[$i]->getModifiedStamp() < $before6Months ? 'M d  Y' : 'M d H:i', $elements[$i]->getModifiedStamp()), $elements[$i]->getName());
         $this->cat && $this->cat->debug('    ', $buf);
         $dataSocket->write($buf . $this->eol($this->sessions[$socket->hashCode()]->getType()));
     }
     $dataSocket->close();
     $this->answer($socket, 226, 'Transfer complete');
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:48,代码来源:FtpProtocol.class.php

示例3: testNonLeapYear

 public function testNonLeapYear()
 {
     $date = Date::create(1999, 2, 1, 0, 0, 0, new TimeZone('Europe/Berlin'));
     $this->assertEquals(Date::create(1999, 3, 1, 0, 0, 0, new TimeZone('Europe/Berlin')), DateUtil::addMonths($date, 1));
     $this->assertEquals(Date::create(1999, 3, 3, 0, 0, 0, new TimeZone('Europe/Berlin')), DateUtil::addDays($date, 30));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:6,代码来源:DateUtilTest.class.php


注:本文中的DateUtil::addMonths方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。