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

Source for file modifier.bit_date_format.php

Documentation is available at modifier.bit_date_format.php

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8. /**
  9.  * required setup
  10.  */
  11. global $gBitSmarty;
  12. $gBitSmarty->loadPlugin('smarty_shared_make_timestamp');
  13.  
  14. /**
  15.  * Smarty plugin
  16.  * -------------------------------------------------------------
  17.  * Type:     modifier
  18.  * Name:     bit_date_format
  19.  * Purpose:  format datestamps via strftime, (timezone adjusted to administrator specified timezone)
  20.  * Input:    string: input date string
  21.  *           format: strftime format for output
  22.  * -------------------------------------------------------------
  23.  */
  24. function smarty_modifier_bit_date_format( $pString, $format = "%b %e, %Y", $pTraFormat = "%b %e, %Y" ) {
  25.     global $gBitSystem, $gBitUser, $gBitLanguage;
  26.  
  27.     if( empty( $pString )) {
  28.         return '';
  29.     }
  30.  
  31.     // we translate the entire date format string for total control
  32.     if( $gBitSystem->getConfig( "bitlanguage", "en" ) != $gBitLanguage->mLanguage ) {
  33.         $format = tra( $pTraFormat );
  34.     }
  35.  
  36.     if( $gBitUser->getPreference( 'site_display_utc' ) == 'Fixed' && class_exists( 'DateTime' ) ) {
  37.         date_default_timezone_set( $gBitUser->getPreference( 'site_display_timezone', 'UTC' ) );
  38.         if ( is_numeric( $pString )) {
  39.             $dateTimeUser = new DateTime( '@'.(int)$pString );
  40.         } else  {
  41.             $dateTimeUser = new DateTime( $pString );
  42.         }
  43.         $disptime = strtotime($dateTimeUser->format(DATE_W3C));
  44.         return $gBitSystem->mServerTimestamp->strftime( $format, $disptime );
  45.     } else {
  46.          if( $gBitSystem->get_display_offset() ) {
  47.             $format = preg_replace( "/ ?%Z/",'', $format );
  48.         } else {
  49.             $format = preg_replace( "/%Z/", "UTC", $format );
  50.         }
  51.         $disptime = $gBitSystem->mServerTimestamp->getDisplayDateFromUTC( $pString );
  52.     }
  53.     return $gBitSystem->mServerTimestamp->strftime( $format, $disptime, TRUE );
  54. }
  55. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:09 +0000 by phpDocumentor 1.5.0-lsces