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


PHP CBPTXT::Tdate方法代码示例

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


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

示例1: getFormattedValidity

	/**
	 * Renders a calendar or time-period validity period, e.g. Year 2007, March - May 2007, December 2006 - January 2007, etc.
	 *
	 * @param  int|null  $expiryTime   Unix-time
	 * @param  int|null  $startTime    Unix-time
	 * @param  string    $varName      variable name ( 'validity' (default) or 'first_validity' )
	 * @param  string    $reason       payment reason: 'N'=new subscription (default), 'R'=renewal, 'U'=update (needed only if $expiryTime is NULL)
	 * @param  int       $occurrences  number of occurrences (needed only if $expiryTime is NULL)
	 * @param  boolean   $displayOne   Display significant 1s also if it's 1: e.g. TRUE: 1 year, FALSE: year
	 * @param  boolean   $html         true: Display for html with non-breaking spaces
	 * @return string
	 */
	public function getFormattedValidity( $expiryTime, $startTime, $varName, $reason = null, $occurrences = 1, $displayOne = true, $html = false ) {
		global $_CB_framework;

		$this->fixVarName( $varName );

		$text = '';
		if ( $this->isCalendarValidity( $varName ) ) {
			$offset		=	(int) $_CB_framework->getCfg( 'offset' ) * 3600;
			$now		=	$_CB_framework->now();
			if ( $startTime === null ) {
				$startTime = $now;
			}
			if ( $expiryTime === null ) {
				$expiryTime = $this->getExpiryTime( $startTime, $varName, $occurrences, $reason );		// WARNING: adjusts $startTime to the real Start-time, which is wanted here
			}
			$now		+= $offset;
			$startTime	+= $offset;
			$expiryTime	+= $offset;
			$isValid	= ( /*removed otherwise renew buttons display wrong: ( $startTime <= $now  ) && */ ( $now < $expiryTime ) );
			list( $y, $c, $d, /* $h */, /* $m */, /* $s */ ) = $this->getValidity( $varName );	// = sscanf( substr( $this->get( $varName ), 2 ), '%d-%d-%d %d:%d:%d' );
			list( $yn, $cn, $dn )	=	sscanf( date( 'Y-m-d', $now ),		  '%d-%d-%d' );
			list( $ys, $cs, $ds )	=	sscanf( date( 'Y-m-d', $startTime ),  '%d-%d-%d' );
			list( $ye, $ce, $de )	=	sscanf( date( 'Y-m-d', $expiryTime ), '%d-%d-%d' );
			$calStart	=	$this->calendarYearStart( $varName );
			if ( $y && ( $calStart == '01-01' ) ) {
				if ( ( $y == 1 ) && ( $ye <= ( $ys + 1 ) ) ) {
					$text .= sprintf( $this->_htmlNbsp( CBPTXT::T("Year %s"), $html ), $ye );						// 'Year 2007'
					if ( $ye != $yn && $isValid ) {
						$text .= ' (' . CBPTXT::T("valid from now on") . ')';
					}
				} else {
					$years = $ye - $ys + 1;
					if ( ( ! $isValid ) || ( ( $y == $years ) && ( $ys == $yn ) ) ) {
						$text .= sprintf( $this->_htmlNbsp( CBPTXT::T("Years %s - %s"), $html ), $ys, $ye );		// 'Years 2006 - 2007'
					} else {
						if ( $y == $years ) {
							$text .= sprintf( $this->_htmlNbsp( CBPTXT::T("Years %s - %s"), $html ), $ys, $ye );	// 'Years 2007 - 2008'
						} else {
							$text .= sprintf( $this->_htmlNbsp( CBPTXT::T("Years %s - %s"), $html ), $ys + 1, $ye ); // 'Years 2007 - 2008'
						}
						$text .= ' (' . CBPTXT::T("valid from now on") . ')';
					}
				}
			} elseif ( $c || $y ) {
				if ( ( $calStart != '01-01' ) && ! preg_match( '/$..-01/', $calStart ) ) {
					// $text .= $calStart . date( 'Y-m-d H:i:s', $startTime ) .( $c + ( $y * 12 ) ) . '_' . ($ce - $cs + 1 + ( ( $ye - $ys ) * 12 )) . '_';
					$text .= CBPTXT::Tdate( 'j F', $startTime) . ( ( $ys != $ye ) ? $this->_htmlNbsp( ' ', $html ) . $ys : '' );	// 'January' or 'December 2006'
					$text .= $this->_htmlNbsp( ' - ', $html );														// ' - '
					$text .= CBPTXT::Tdate( 'j F', $expiryTime) . $this->_htmlNbsp( ' ', $html ) . $ye;						// 'February 2007'
					if ( ( ! ( ( $cs == $cn ) && ( $ys == $yn ) ) ) && $isValid ) {
						$text .= ' (' . CBPTXT::T("valid from now on") . ')';
					}
				} else {
					$months = $ce - $cs + 1 + ( ( $ye - $ys ) * 12 );
					if ( ( ( $c == 1 ) && ( $y == 0 ) ) || ( $months == 1 ) ) {
						$text .= CBPTXT::Tdate( 'F', $expiryTime) . $this->_htmlNbsp( ' ', $html ) . $ye;		// 'January 2007'
						if ( $ce != $cn  && $isValid ) {
							$text .= ' (' . CBPTXT::T("valid from now on") . ')';
						}
					} else {
						// if ( ( $c + ( $y * 12 ) ) == $months ) {
						$text .= CBPTXT::Tdate( 'F', $startTime) . ( ( $ys != $ye ) ? $this->_htmlNbsp( ' ', $html ) . $ys : '' );	// 'January' or 'December 2006'
						$text .= $this->_htmlNbsp( ' - ', $html );														// ' - '
						$text .= CBPTXT::Tdate( 'F', $expiryTime) . $this->_htmlNbsp( ' ', $html ) . $ye;						// 'February 2007'
						if ( ( ! ( ( $cs == $cn ) && ( $ys == $yn ) ) ) && $isValid ) {
							$text .= ' (' . CBPTXT::T("valid from now on") . ')';
						}
						// } else {		//TBD: check if this else is still needed
						/*	list($ynn, $cnn, $dnn, $hnn, $mnn, $snn) = sscanf( date( 'Y-m-d H:i:s', $startTime ), '%d-%d-%d %d:%d:%d' );
							$cnn += 2;
							$dnn = 0;
							$nextMonthTime = mktime($hnn, $mnn, $snn, $cnn, $dnn, $ynn);
							$text .= date( 'F', $nextMonthTime) . ( ( $ynn != $ye ) ? $this->_htmlNbsp( ' ', $html ) . $ynn : '' );	// 'January' or 'December 2006'
							$text .= $this->_htmlNbsp( ' - ', $html );														// ' - '
							$text .= date( 'F', $expiryTime) . $this->_htmlNbsp( ' ', $html ) . $ye;						// 'February 2007'
							if ( $isValid ) {
								$text .= ' (' . CBPTXT::T("valid from now on") . ')';
							}
						*/
						// }
					}
				}
			} elseif ( $d ) {
				if ( $de == $dn ) {
					$text .= CBPTXT::T("Today");
				} elseif ( ( $de == ( $dn + 1 ) ) || ( ( $de == 1 ) && ( ( $expiryTime - $now ) < 48*3600 ) ) ) {
					if ( $d == 1 ) {
						$text .= CBPTXT::T("Tomorrow");
//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:cbpaidTimed.php

示例2: getFormattedValidity

 /**
  * Renders a calendar or time-period validity period, e.g. Year 2007, March - May 2007, December 2006 - January 2007, etc.
  *
  * @param  int|null  $expiryTime   Unix-time
  * @param  int|null  $startTime    Unix-time
  * @param  string    $varName      variable name ( 'validity' (default) or 'first_validity' )
  * @param  string    $reason       payment reason: 'N'=new subscription (default), 'R'=renewal, 'U'=update (needed only if $expiryTime is NULL)
  * @param  int       $occurrences  number of occurrences (needed only if $expiryTime is NULL)
  * @param  boolean   $displayOne   Display significant 1s also if it's 1: e.g. TRUE: 1 year, FALSE: year
  * @param  boolean   $html         true: Display for html with non-breaking spaces
  * @param  string    $status       status of subscription
  * @return string
  */
 public function getFormattedValidity($expiryTime, $startTime, $varName, $reason = null, $occurrences = 1, $displayOne = true, $html = false, $status = 'I')
 {
     $this->fixVarName($varName);
     $text = '';
     if ($this->isCalendarValidity($varName)) {
         $now = cbpaidTimes::getInstance()->startTime();
         if ($startTime === null) {
             $startTime = $now;
         }
         if ($expiryTime === null) {
             $expiryTime = $this->getExpiryTime($startTime, $varName, $occurrences, $reason, $status);
             // WARNING: adjusts $startTime to the real Start-time, which is wanted here
         }
         $isValid = $now < $expiryTime;
         list($y, $c, $d, , , ) = $this->getValidity($varName);
         // = sscanf( substr( $this->get( $varName ), 2 ), '%d-%d-%d %d:%d:%d' );
         list($yn, $cn, $dn) = sscanf(cbpaidTimes::getInstance()->localDate('Y-m-d', $now), '%d-%d-%d');
         list($ys, $cs, $ds) = sscanf(cbpaidTimes::getInstance()->localDate('Y-m-d', $startTime), '%d-%d-%d');
         list($ye, $ce, $de) = sscanf(cbpaidTimes::getInstance()->localDate('Y-m-d', $expiryTime), '%d-%d-%d');
         $calStart = $this->calendarYearStart($varName);
         if ($y && $calStart == '01-01') {
             if ($y == 1 && $ye <= $ys + 1) {
                 $text .= sprintf($this->_htmlNbsp(CBPTXT::T("Year %s"), $html), $ye);
                 // 'Year 2007'
                 if ($ye != $yn && $isValid) {
                     $text .= ' (' . CBPTXT::T("valid from now on") . ')';
                 }
             } else {
                 $years = $ye - $ys + 1;
                 if (!$isValid || $y == $years && $ys == $yn) {
                     $text .= sprintf($this->_htmlNbsp(CBPTXT::T("Years %s - %s"), $html), $ys, $ye);
                     // 'Years 2006 - 2007'
                 } else {
                     if ($y == $years) {
                         $text .= sprintf($this->_htmlNbsp(CBPTXT::T("Years %s - %s"), $html), $ys, $ye);
                         // 'Years 2007 - 2008'
                     } else {
                         $text .= sprintf($this->_htmlNbsp(CBPTXT::T("Years %s - %s"), $html), $ys + 1, $ye);
                         // 'Years 2007 - 2008'
                     }
                     $text .= ' (' . CBPTXT::T("valid from now on") . ')';
                 }
             }
         } elseif ($c || $y) {
             if ($calStart != '01-01' && !preg_match('/$..-01/', $calStart)) {
                 // $text .= $calStart . date( 'Y-m-d H:i:s', $startTime ) .( $c + ( $y * 12 ) ) . '_' . ($ce - $cs + 1 + ( ( $ye - $ys ) * 12 )) . '_';
                 $text .= CBPTXT::Tdate('j F', $startTime) . ($ys != $ye ? $this->_htmlNbsp(' ', $html) . $ys : '');
                 // 'January' or 'December 2006'
                 $text .= $this->_htmlNbsp(' - ', $html);
                 // ' - '
                 $text .= CBPTXT::Tdate('j F', $expiryTime) . $this->_htmlNbsp(' ', $html) . $ye;
                 // 'February 2007'
                 if (($ys > $yn || $cs > $cn && $ys == $yn) && $isValid) {
                     $text .= ' (' . CBPTXT::T("valid from now on") . ')';
                 }
             } else {
                 $months = $ce - $cs + 1 + ($ye - $ys) * 12;
                 if ($c == 1 && $y == 0 || $months == 1) {
                     $text .= CBPTXT::Tdate('F', $expiryTime) . $this->_htmlNbsp(' ', $html) . $ye;
                     // 'January 2007'
                     if ($ce != $cn && $isValid) {
                         $text .= ' (' . CBPTXT::T("valid from now on") . ')';
                     }
                 } else {
                     // if ( ( $c + ( $y * 12 ) ) == $months ) {
                     $text .= CBPTXT::Tdate('F', $startTime) . ($ys != $ye ? $this->_htmlNbsp(' ', $html) . $ys : '');
                     // 'January' or 'December 2006'
                     $text .= $this->_htmlNbsp(' - ', $html);
                     // ' - '
                     $text .= CBPTXT::Tdate('F', $expiryTime) . $this->_htmlNbsp(' ', $html) . $ye;
                     // 'February 2007'
                     if (!($cs == $cn && $ys == $yn) && $isValid) {
                         $text .= ' (' . CBPTXT::T("valid from now on") . ')';
                     }
                     // } else {		//TBD: check if this else is still needed
                     /*	list($ynn, $cnn, $dnn, $hnn, $mnn, $snn) = sscanf( gmdate( 'Y-m-d H:i:s', $startTime ), '%d-%d-%d %d:%d:%d' );
                     				$cnn += 2;
                     				$dnn = 0;
                     				$nextMonthTime = mktime($hnn, $mnn, $snn, $cnn, $dnn, $ynn);
                     				$text .= gmdate( 'F', $nextMonthTime) . ( ( $ynn != $ye ) ? $this->_htmlNbsp( ' ', $html ) . $ynn : '' );	// 'January' or 'December 2006'
                     				$text .= $this->_htmlNbsp( ' - ', $html );														// ' - '
                     				$text .= gmdate( 'F', $expiryTime) . $this->_htmlNbsp( ' ', $html ) . $ye;						// 'February 2007'
                     				if ( $isValid ) {
                     					$text .= ' (' . CBPTXT::T("valid from now on") . ')';
                     				}
                     			*/
                     // }
//.........这里部分代码省略.........
开发者ID:jasonrgd,项目名称:Digital-Publishing-Platform-Joomla,代码行数:101,代码来源:cbpaidTimed.php

示例3: _renderPeriodOfValiditiy

 /**
  * Returns formatted time period ( xxx weeks , or xxx years xxx months xxx days xxx hours xxx minutes xxx seconds
  *
  * @param  string        $varName                    'validity' or 'fist_validity'
  * @param  int           $occurrences                [default: 1] multiply period by the occurrences before displaying
  * @param  boolean       $displayOne                 [default: true] displays also if only 1 unit of something
  * @param  boolean       $displayCalendarYearStart   [default: true] displays start of calendar year if not January 1st
  * @return string
  */
 private function _renderPeriodOfValiditiy($varName, $occurrences = 1, $displayOne = true, $displayCalendarYearStart = true)
 {
     $ycdhmsArray = $this->getValidity($varName);
     $prefix = $this->isCalendarValidity($varName) ? CBPTXT::T("calendar ") : '';
     $text = $this->renderPeriod($ycdhmsArray, $occurrences, $displayOne, $prefix);
     $calStart = $this->calendarYearStart($varName);
     if ($prefix && $calStart != '01-01' && $displayCalendarYearStart) {
         list($m, $d) = explode('-', $calStart);
         $text .= ' ' . CBPTXT::T("starting") . ' ' . CBPTXT::Tdate('F j', cbpaidTimes::getInstance()->localStrToTime((int) $m . '/' . (int) $d));
     }
     return $text;
 }
开发者ID:jasonrgd,项目名称:Digital-Publishing-Platform-Joomla,代码行数:21,代码来源:cbpaidItem.php


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