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


PHP MWTimestamp::getHumanTimestamp方法代码示例

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


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

示例1: testHumanTimestamp

 /**
  * @test
  * @dataProvider provideHumanTimestampTests
  */
 public function testHumanTimestamp($tsTime, $currentTime, $timeCorrection, $dateFormat, $expectedOutput, $desc)
 {
     $user = $this->getMock('User');
     $user->expects($this->any())->method('getOption')->with('timecorrection')->will($this->returnValue($timeCorrection));
     $user->expects($this->any())->method('getDatePreference')->will($this->returnValue($dateFormat));
     $tsTime = new MWTimestamp($tsTime);
     $currentTime = new MWTimestamp($currentTime);
     $this->assertEquals($expectedOutput, $tsTime->getHumanTimestamp($currentTime, $user), $desc);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:13,代码来源:TimestampTest.php

示例2: getLineHtml

 /**
  * Gets the HTML fragment for a watched page.
  *
  * @param Title $title The title of the watched page
  * @param int $ts When the page was last touched
  * @param string $thumb An HTML fragment for the page's thumbnaiL
  * @return string
  */
 public static function getLineHtml(Title $title, $ts, $thumb)
 {
     $titleText = $title->getPrefixedText();
     if ($ts) {
         $ts = new MWTimestamp($ts);
         $lastModified = wfMessage('mobile-frontend-watchlist-modified', $ts->getHumanTimestamp())->text();
         $className = 'title';
     } else {
         $className = 'title new';
         $lastModified = '';
     }
     $html = Html::openElement('li', array('class' => 'page-summary', 'title' => $titleText, 'data-id' => $title->getArticleId())) . Html::openElement('a', array('href' => $title->getLocalUrl(), 'class' => $className));
     $html .= $thumb;
     $html .= Html::element('h3', array(), $titleText) . Html::element('div', array('class' => 'info'), $lastModified) . Html::closeElement('a') . Html::closeElement('li');
     return $html;
 }
开发者ID:GoProjectOwner,项目名称:mediawiki-extensions-MobileFrontend,代码行数:24,代码来源:SpecialMobileEditWatchlist.php

示例3: testHumanOutput

 /**
  * Test human readable timestamp format.
  */
 function testHumanOutput()
 {
     $timestamp = new MWTimestamp(time() - 3600);
     $this->assertEquals("1 hour ago", $timestamp->getHumanTimestamp()->inLanguage('en')->text());
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:8,代码来源:TimestampTest.php

示例4: execute

 function execute($par)
 {
     if (!in_array('staff', $this->getUser()->getGroups())) {
         $this->getOutput()->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $target = $this->getRequest()->getVal("target");
     if ($target) {
         if (is_numeric($target)) {
             $target = User::whoIs(intval($target));
         } else {
             $target = User::newFromName($target);
         }
     }
     $month_1 = $this->padVar("month_1") ?: date("m");
     $day_1 = $this->padVar("day_1") ?: date("d");
     $hour_1 = $this->padVar("hour_1") ?: "00";
     $month_2 = $this->padVar("month_2") ?: "";
     $day_2 = $this->padVar("day_2") ?: "";
     $hour_2 = $this->padVar("hour_2") ?: "00";
     $this->getOutput()->addHTML("\n\t\t\t<form action='/Special:UnpatrolTips' method='POST'>\n\t\t\t\tUsername: <input type='text' name='target' value='{$target}'/> <br/><br/>\n\t\t\t\tStart date: Year: " . date("Y") . " Month: <input type='text' name='month_1' size='2' value='" . $month_1 . "'/>\n\t\t\t\t\t\tDay: <input type='text' name='day_1' size='2' value='" . $day_1 . "'>\n\t\t\t\t\t\tHour (GMT): <input type='text' name='hour_1' size='2' value='" . $hour_1 . "'> <br/><br/>\n\t\t\t\tEnd date (optional): Year: " . date("Y") . " <input type='text' name='month_2' size='2' value='" . $month_2 . "'>\n\t\t\t\t\t\tDay: <input type='text' name='day_2' size='2' value='" . $day_2 . "'>\n\t\t\t\t\t\tHour (GMT): <input type='text' name='hour_2' size='2' value='" . $hour_2 . "'> <br/><br/>\n\t\t\t\t<input type='submit' name='count' value='Count'/>\n\t\t\t\t<input type='submit' name='view' value='View'/>\n\t\t\t\t<input type='submit' name='update' value='Submit'/>\n\t\t\t</form>\t");
     if ($this->getRequest()->wasPosted()) {
         $user = $target;
         if (!$user || $user->getID() == 0) {
             $this->getOutput()->addHTML("Invalid user.  {$this->getRequest()->getVal('username', '')}");
             return;
         }
         $start = date("Y") . $month_1 . $day_1 . $hour_1 . "0000";
         $cutoff = wfTimestamp(TS_MW, $start);
         $cutoffDisplay = new MWTimestamp($start);
         $humanCutoff = $cutoffDisplay->getHumanTimestamp();
         $end = null;
         $cutoff2 = null;
         if ($month_2) {
             $end = date("Y") . $month_2 . $day_2 . $hour_2 . "0000";
             $cutoffDisplay2 = new MWTimestamp($end);
             $humanCutoff2 = $cutoff2->getHumanTimestamp();
             $cutoff2 = wfTimestamp(TS_MW, $end);
         }
         if ($this->getRequest()->getVal("count")) {
             if (!$end) {
                 $this->getOutput()->addHTML("changes by {$user} since {$humanCutoff}<br/>");
             } else {
                 $this->getOutput()->addHTML("changes by {$user} between {$humanCutoff} and {$humanCutoff} <br/>");
             }
             $results = $this->revertTips($user, $cutoff, $cutoff2, false, false);
             $this->getOutput()->addHTML("<br/>");
             if ($results > 0) {
                 $this->getOutput()->addHTML("there are " . $results . " tips sent to QG by {$user->getName()} for this date range<br/>");
             } else {
                 $this->getOutput()->addHTML("There were no tips patrolled to show for this time frame.<br/>");
             }
         } else {
             if ($this->getRequest()->getVal("view")) {
                 if (!$end) {
                     $this->getOutput()->addHTML("showing changes by {$user} since {$humanCutoff}<br/>");
                 } else {
                     $this->getOutput()->addHTML("showing changes by {$user} between {$humanCutoff} and {$humanCutoff} <br/>");
                 }
                 $results = $this->revertTips($user, $cutoff, $cutoff2, false, true);
                 $this->getOutput()->addHTML("<br/>");
                 if ($results > 0) {
                     $this->getOutput()->addHTML("showing " . $results . " tips sent to QG by {$user->getName()} for this date range</br>");
                 } else {
                     $this->getOutput()->addHTML("There were no tips patrolled to show for this time frame.<br/>");
                 }
             } else {
                 $this->getOutput()->addHTML("<br/>");
                 if (!$end) {
                     $this->getOutput()->addHTML("reverting changes by {$user} since {$humanCutoff}<br/>");
                 } else {
                     $this->getOutput()->addHTML("reverting changes by {$user} between {$humanCutoff} and {$humanCutoff} <br/>");
                 }
                 $unpatrolled = $this->revertTips($user, $cutoff, $cutoff2, true);
                 if ($unpatrolled > 0) {
                     $this->getOutput()->addHTML("Undid " . $unpatrolled . " tips patrolled by {$user->getName()}\n");
                 } else {
                     $this->getOutput()->addHTML("There were no tips unpatrolled.<br/>");
                 }
             }
         }
     }
     return;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:84,代码来源:Unpatrol.body.php

示例5: testHumanOutput

 /**
  * Test human readable timestamp format.
  */
 function testHumanOutput()
 {
     $timestamp = new MWTimestamp(time() - 3600);
     $this->assertEquals("1 hour ago", $timestamp->getHumanTimestamp()->toString());
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:8,代码来源:TimestampTest.php

示例6: getHumanTimestamp

 public function getHumanTimestamp($timestamp)
 {
     $ts = new \MWTimestamp($timestamp);
     return $ts->getHumanTimestamp();
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:5,代码来源:RevisionViewFormatter.php

示例7: showHeader

 /**
  * Render the header of a diff page including:
  * Name with url to page
  * Bytes added/removed
  * Day and time of edit
  * Edit Comment
  */
 function showHeader()
 {
     $title = $this->targetTitle;
     if ($this->prevRev) {
         $bytesChanged = $this->rev->getSize() - $this->prevRev->getSize();
     } else {
         $bytesChanged = $this->rev->getSize();
     }
     if ($bytesChanged > 0) {
         $changeMsg = 'mobile-frontend-diffview-bytesadded';
         $sizeClass = MobileUI::iconClass('bytesadded', 'before', 'icon-12px meta mw-mf-bytesadded');
     } elseif ($bytesChanged === 0) {
         $changeMsg = 'mobile-frontend-diffview-bytesnochange';
         $sizeClass = MobileUI::iconClass('bytesneutral', 'before', 'icon-12px meta mw-mf-bytesneutral');
     } else {
         $changeMsg = 'mobile-frontend-diffview-bytesremoved';
         $sizeClass = MobileUI::iconClass('bytesremoved', 'before', 'icon-12px meta mw-mf-bytesremoved');
         $bytesChanged = abs($bytesChanged);
     }
     if ($this->rev->isMinor()) {
         $minor = ChangesList::flag('minor');
     } else {
         $minor = '';
     }
     if ($this->rev->getComment() !== '') {
         $comment = Linker::formatComment($this->rev->getComment(), $title);
     } else {
         $comment = $this->msg('mobile-frontend-changeslist-nocomment')->escaped();
     }
     $ts = new MWTimestamp($this->rev->getTimestamp());
     $this->getOutput()->addHtml(Html::openElement('div', array('id' => 'mw-mf-diff-info', 'class' => 'page-summary')) . Html::openElement('h2', array()) . Html::element('a', array('href' => $title->getLocalURL()), $title->getPrefixedText()) . Html::closeElement('h2') . $this->msg('mobile-frontend-diffview-comma')->rawParams(Html::element('span', array('class' => $sizeClass), $this->msg($changeMsg)->numParams($bytesChanged)->text()), Html::element('span', array('class' => 'mw-mf-diff-date meta'), $ts->getHumanTimestamp()))->text() . Html::closeElement('div') . $minor . Html::rawElement('div', array('id' => 'mw-mf-diff-comment'), $comment));
 }
开发者ID:felixonmars,项目名称:mediawiki-extensions-MobileFrontend,代码行数:39,代码来源:SpecialMobileDiff.php

示例8: makeRequestItem

    protected function makeRequestItem($request)
    {
        $requestdataEnc = htmlspecialchars(FormatJson::encode($request));
        $nameEnc = htmlspecialchars($request['username']);
        $nameEncForId = htmlspecialchars(Sanitizer::escapeId($request['username']));
        $emailEnc = htmlspecialchars($request['email']);
        $countEnc = htmlspecialchars($request['translations']);
        $timestamp = new MWTimestamp($request['registrationdate']);
        $agoEnc = htmlspecialchars($timestamp->getHumanTimestamp());
        return <<<HTML
<div class="row request" data-data="{$requestdataEnc}" id="tsb-request-{$nameEncForId}">
\t<div class="two columns amount">
\t\t<div class="translation-count">{$countEnc}</div>
\t</div>
\t<div class="seven columns request-info">
\t\t<div class="row username">{$nameEnc}</div>
\t\t<div class="row email">{$emailEnc}</div>
\t</div>
\t<div class="three columns approval center">
\t\t<input class="row request-selector" name="request" type="checkbox" />
\t\t<div class="row signup-age">{$agoEnc}</div>
\t</div>
</div>
HTML;
    }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:25,代码来源:SpecialManageTranslatorSandbox.php

示例9: formatTimestamp

 /**
  * Formats a timestamp in a human-readable format
  * @param $ts string Timestamp in some format compatible with wfTimestamp()
  * @return string Human-readable timestamp
  */
 protected function formatTimestamp($ts)
 {
     $timestamp = new MWTimestamp($ts);
     $ts = $timestamp->getHumanTimestamp();
     return $ts;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:11,代码来源:NotificationFormatter.php

示例10: testTimeUnit

 /** @dataProvider providerTimeUnit */
 function testTimeUnit($language, $tsTime, $currentTime, $expectedOutput, $desc)
 {
     $tsTime = new MWTimestamp($tsTime);
     $currentTime = new MWTimestamp($currentTime);
     $this->assertEquals($expectedOutput, $tsTime->getHumanTimestamp($currentTime, null, Language::factory($language)), $desc);
 }
开发者ID:Plover-Y,项目名称:mediawiki-extensions-cldr,代码行数:7,代码来源:TimeUnitsTest.php


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