creates formatted output for calendar component property rdate

@author Kjell-Inge Gustafsson <ical@kigkonsult.se>
@since 1.x.x - 2007-05-13
@param bool $localtime optional, default FALSE
@return string
358541
function createRdate( $localtime=FALSE ) {
    $cnt = count( $this->rdate );
    if( 0 >= $cnt )
      return;
    $output = null;
    foreach( $this->rdate as $theRdate ) {
      $attributes = $this->_createParams( $theRdate['params'] );
      $cnt = count( $theRdate['value'] );
      $content = null;
      $rno = 1;
      foreach( $theRdate['value'] as $rpix =>$rdatePart ) {
        $contentPart = null;
        if( is_array( $rdatePart ) &&
           ( 2 == count( $rdatePart )) &&
             array_key_exists( '0', $rdatePart ) &&
             array_key_exists( '1', $rdatePart )) { // PERIOD
          if( $localtime  )
            unset( $rdatePart[0]['tz'] );
          $formatted = $this->_format_date_time( $rdatePart[0]);
          if( isset( $theRdate['params']['TZID'] ))
            $formatted = str_replace( 'Z', '', $formatted);
          if( 0 < $rpix ) {
            if( isset( $rdatePart[0]['tz'] ) &&
               ( ctype_digit( substr( $rdatePart[0]['tz'], -4 )) ||
                  ( 'Z' == $rdatePart[0]['tz'] ))) {
              if( 'Z' != substr( $formatted, -1 ))
                $formatted .= 'Z';
            }
            else
              $formatted = str_replace( 'Z', '', $formatted );
          }
          $contentPart .= $formatted;
          if( 1 == $rno )
            $attributes .= $this->intAttrDelimiter.'VALUE=PERIOD';
          $contentPart .= '/';
          $cnt2 = count( $rdatePart[1]);
          if( array_key_exists( 'year', $rdatePart[1] )) {
            if( array_key_exists( 'hour', $rdatePart[1] ))
              $cnt2 = 7;                                      // date-time
            else
              $cnt2 = 3;                                      // date
          }
          elseif( array_key_exists( 'week', $rdatePart[1] ))  // duration
            $cnt2 = 5;
          if(( 7 == $cnt2 )   &&    // period=  -> date-time
              isset( $rdatePart[1]['year'] )  &&
              isset( $rdatePart[1]['month'] ) &&
              isset( $rdatePart[1]['day'] )) {
            if( $localtime  )
              unset( $rdatePart[1]['tz'] );
            $formatted = $this->_format_date_time( $rdatePart[1] );
            if( isset( $theRdate['params']['TZID'] ))
              $formatted = str_replace( 'Z', '', $formatted);
            if( isset( $rdatePart[0]['tz'] ) &&
              ( ctype_digit( substr( $rdatePart[0]['tz'], -4 )) ||
                  ( 'Z' == $rdatePart[0]['tz'] ))) {
              if( 'Z' != substr( $formatted, -1 ))
                $formatted .= 'Z';
            }
            else
              $formatted = str_replace( 'Z', '', $formatted );
           $contentPart .= $formatted;
          }
          else {                                  // period=  -> dur-time
            $contentPart .= $this->_format_duration( $rdatePart[1] );
          }
        } // PERIOD end
        else { // single date start
          if( $localtime  )
            unset( $rdatePart['tz'] );
          $formatted = $this->_format_date_time( $rdatePart);
          if( isset( $theRdate['params']['TZID'] ))
            $formatted = str_replace( 'Z', '', $formatted);
          if( 0 < $rpix ) {
            $firstPart = ( 2 == count( $theRdate['value'][0] ))
                       ? $theRdate['value'][0][0] : $theRdate['value'][0];
            if( isset( $firstPart['tz'] ) &&
               ( ctype_digit( substr( $firstPart['tz'], -4 )) ||
                  ( 'Z' == $firstPart['tz'] ))) {
              if( 'Z' != substr( $formatted, -1 ))
                $formatted .= 'Z';
            }
            else
              $formatted = str_replace( 'Z', '', $formatted );
          }
          $contentPart .= $formatted;
        }
        $content .= $contentPart;
        if( $rno < $cnt )
          $content .= ',';
        $rno++;
      }
      $output    .= $this->_createElement( 'RDATE', $attributes, $content );
    }
    return $output;
  }
661565
public static Date toUtcDate(TimeZone browserTZ, TimeZone targetTZ, String localDate) {
        if (localDate == null) {
            return null;
        }

        return toUtcDate(browserTZ, targetTZ, Long.valueOf(localDate));
    }
1171594
static function createForMIME( $mimeData )
    {
        $analyzerData = eZImageAnalyzer::analyzerData();
        $mimeType = $mimeData['name'];
        if ( !isset( $analyzerData['analyzer_map'][$mimeType] ) )
            return false;
        $analyzerName = $analyzerData['analyzer_map'][$mimeType];
        $handlerName = $analyzerData['analyzer'][$analyzerName]['handler'];
        return eZImageAnalyzer::create( $handlerName );
    }
1110153
public static String formatDate(java.util.Date pDate, String format) {

        if (pDate == null) {
            pDate = new java.util.Date();
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(pDate);
    }
1059648
private function udate($format = 'u', $utimestamp = null)
    {
        $utimestamp = is_null($utimestamp) ? microtime(true) : $utimestamp;
        $timestamp = floor($utimestamp);
        $milliseconds = round(($utimestamp - $timestamp) * 1000000);

        return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp);
    }
677008
static public function microTime($isFormat = true)
    {
        if ($isFormat) {
            list($microSec, $sec) = explode(" ", microtime());
            return Format::datetime($sec) . ' ' . substr($microSec, 2, 6);
        } else {
            return microtime(true);
        }
    }
1257333
protected function getFormatterTime($locale) {
		if (! isset($this->formattersTime[$locale])) {
			$this->formattersTime[$locale] = new IntlDateFormatter($locale, IntlDateFormatter::NONE, IntlDateFormatter::MEDIUM);
		}
		
		return $this->formattersTime[$locale];
	}
501215
public static function getDateFormat($locale = null)
    {
        $format = Zend_Locale_Data::getContent($locale, 'date');
        if (empty($format)) {

            throw new Zend_Locale_Exception("failed to receive data from locale $locale");
        }

        return $format;
    }
113278
public static function createFromFormat($format, $time, $object = null)
    {
        if ($object !== null) {
            $dt = parent::createFromFormat($format, $time, $object);
        } else {
            $dt = parent::createFromFormat($format, $time);
        }

        $lastErrors = parent::getLastErrors();

        if ($dt instanceof \DateTimeInterface) {
            return new static($dt->format('Y-m-d H:i:s.u'), $dt->getTimezone());
        }

        throw new \InvalidArgumentException(implode(PHP_EOL, $lastErrors['errors']));
    }
320458
function setRdate( $rdates, $params=FALSE ) {
    $input = array();
    $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
    $this->_existRem( $input['params'], 'VALUE', 'PERIOD' );
    $parno = ( isset( $input['params']['TZID'] )) ? 6 : null;
    $parno = ( !$parno ) ? $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ) : null;
    $parno = ( !$parno ) ? $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 ) : 6;
    $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' );
    foreach( $rdates as $theRdate ) {
 //   echo 'setRdate in '; print_r ( $theRdate ); echo "<br />\n"; // test ##
      $inputa = null;
      if( is_array( $theRdate )) {
        if(( 2 == count( $theRdate )) &&
             array_key_exists( '0', $theRdate ) &&
             array_key_exists( '1', $theRdate ) &&
            !array_key_exists( 'timestamp', $theRdate )) { // PERIOD
          foreach( $theRdate as $rix => $rPeriod ) {
 //   echo 'setRdate i2 '; print_r ( $rPeriod ); echo "<br />\n"; // test ##
            if( is_array( $rPeriod )) {
 //   echo 'setRdate i3 '; print_r ( $rPeriod ); echo "<br />\n"; // test ##
              if (( 1 == count( $rPeriod )) &&
                  ( 8 <= strlen( reset( $rPeriod )))) { // text-date
 //   echo 'setRdate i4 '; print_r ( $rPeriod ); echo "<br />\n"; // test ##
                $inputab       = $this->_date_time_string( reset( $rPeriod ), $parno );
                if ( isset( $input['params']['TZID'] ))
                  $inputab['tz'] = (string) $input['params']['TZID'];
                elseif( isset( $inputab['tz'] ))
                  $inputab['tz'] = (string) $inputab['tz'];
                else
                  unset( $inputab['tz'] );
                $parno         = ( !isset( $parno )) ? count( $inputab ) : $parno;
                if(( 7 == $parno ) && !isset( $inputab['tz'] ))
                  $inputab['tz'] = 'Z';
                if( isset( $inputab['tz'] ))
                  $inputab['tz'] = (string) $inputab['tz'];
                $inputa[] = $inputab;
              }
              elseif (((3 == count( $rPeriod )) && ( $rix < 1 )) ||
                      ( 6 == count( $rPeriod )) ||
                      ( 7 == count( $rPeriod )) ||
                      ( array_key_exists( 'year', $rPeriod ))) { // date[-time] (only 1st rperiod)
                if( !isset( $parno ) && 3 < count( $rPeriod ))
                  $parno = 7;
                $inputab       = $this->_date_time_array( $rPeriod, $parno );
                if ( isset( $input['params']['TZID'] ))
                  $inputab['tz'] = (string) $input['params']['TZID'];
                elseif( isset( $inputab['tz'] ))
                  $inputab['tz'] = (string) $inputab['tz'];
                else
                  unset( $inputab['tz'] );
                $parno         = ( !isset( $parno )) ? count( $inputab ) : $parno;
                if(( 7 == $parno ) && !isset( $inputab['tz'] ))
                  $inputab['tz'] = 'Z';
                if( isset( $inputab['tz'] ))
                  $inputab['tz'] = (string) $inputab['tz'];
                $inputa[] = $inputab;
              }
              elseif( isset( $rPeriod['timestamp'] )) {   // timestamp
                $tz    = ( isset( $rPeriod['tz'] ))           ? ' '.$rPeriod['tz']           : null;
                $tz    = ( isset( $input['params']['TZID'] )) ? ' '.$input['params']['TZID'] : $tz;
                if( !isset( $parno )) $parno = ( !empty( $tz )) ? 7 : 6;
                $inputab = $this->_date_time_string( date( 'Y-m-d H:i:s', $rPeriod['timestamp'] ).$tz, $parno );
                if(( 7 == $parno ) && !isset( $inputab['tz'] ))
                  $inputab['tz'] = 'Z';
                if( isset( $inputab['tz'] ))
                  $inputab['tz'] = (string) $inputab['tz'];
                $inputa[] = $inputab;
              }
              else {                                       // array format duration
                $inputa[] = $this->_duration_array( $rPeriod );
              }
            }
            elseif(( 3 <= strlen( trim( $rPeriod ))) &&    // string format duration
                   ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) {
              if( 'P' != $rPeriod{0} )
                $rPeriod = substr( $rPeriod, 1 );
              $inputa[] = $this->_duration_string( $rPeriod );
            }
            elseif( 8 <= strlen( trim( $rPeriod ))) { // ex. 2006-08-03 10:12:18
              $tz    = ( isset( $input['params']['TZID'] )) ? ' '.$input['params']['TZID'] : '';
              $inputab       = $this->_date_time_string( $rPeriod.$tz, $parno );
              if ( isset( $input['params']['TZID'] ))
                $inputab['tz'] = (string) $input['params']['TZID'];
              elseif( isset( $inputab['tz'] ))
                $inputab['tz'] = (string) $inputab['tz'];
              else
                unset( $inputab['tz'] );
              $inputa[]      = $inputab;
              $parno         = ( !isset( $parno )) ? count( $inputab ) : $parno;
            }
          }
        }
        elseif ( array_key_exists( 'timestamp', $theRdate )) {   // timestamp
          $tz    = ( isset( $theRdate['tz'] ))          ? ' '.$theRdate['tz']          : null;
          $tz    = ( isset( $input['params']['TZID'] )) ? ' '.$input['params']['TZID'] : $tz;
          if( !isset( $parno )) $parno = ( !empty( $tz )) ? 7 : 6;
          $inputab = $this->_date_time_string( date( 'Y-m-d H:i:s', $theRdate['timestamp'] ).$tz, $parno );
          if(( 7 == $parno ) && !isset( $inputab['tz'] ))
            $inputab['tz'] = 'Z';
          if( isset( $inputab['tz'] ))
            $inputab['tz'] = (string) $inputab['tz'];
          $inputa = $inputab;
        }
        elseif (( in_array( count( $theRdate ), array( 3, 4, 6, 7 ))) ||
                ( array_key_exists( 'year', $theRdate ))) {  // date[-time]
          if( isset( $input['params']['TZID'] ))
            $theRdate['tz'] = $input['params']['TZID'];
          elseif( !isset( $theRdate['tz'] )) {
            if(( 7 == count( $theRdate )) && isset( $theRdate[6] )) {
              $theRdate['tz'] = $theRdate[6];
              unset( $theRdate[6] );
            }
            elseif(( 4 == count( $theRdate )) && isset( $theRdate[3] )) {
              $theRdate['tz'] = $theRdate[3];
              unset( $theRdate[3] );
            }
          }
          if( !isset( $parno ) && 3 < count( $theRdate ))
            $parno = ( isset( $theRdate['tz'] )) ? 7 : count( $theRdate );
          elseif( !isset( $parno ))
            $parno = 3;
          $inputa = $this->_date_time_array( $theRdate, $parno );
          if(( 7 == $parno ) && !isset( $inputa['tz'] ))
            $inputa['tz'] = 'Z';
          if( isset( $inputa['tz'] ))
            $inputa['tz'] = (string) $inputa['tz'];
        }
      }
      elseif( 8 <= strlen( trim( $theRdate ))) { // ex. 2006-08-03 10:12:18
        $inputa       = $this->_date_time_string( $theRdate, $parno );
        if( isset( $input['params']['TZID'] ))
          $inputa['tz'] = (string) $input['params']['TZID'];
        elseif( isset( $inputa['tz'] ))
          $inputa['tz'] = (string) $inputa['tz'];
        else
          unset( $inputa['tz'] );
        $parno = ( !isset( $parno )) ? count( $inputa ) : $parno;
        if(( 7 == $parno ) && !isset( $inputa['tz'] ))
          $inputa['tz'] = 'Z';
        if( isset( $inputa['tz'] ))
          $inputa['tz'] = (string) $inputa['tz'];
 //         echo 'setRdate inputa single string '; print_r ( $inputa ); echo "<br />\n"; // test ##
      }
      $input['value'][] = $inputa;
    }
    if( 0 < count( $input['value'] )) {
 //     echo 'setRdate ut 1 '; print_r ( $input ); echo "<br />\n"; // test ##
      if( 3 == $parno ) {
        $input['params']['VALUE'] = 'DATE';
        foreach( $input['value'] as $eix => $inputa )
          unset( $input['value'][$eix]['tz'] );
        unset( $input['params']['TZID'] );
      }
      if( empty( $input['value'][0]['tz'] ) ||
         ( $input['value'][0]['tz'] == 'Z' ))
        $dummy = TRUE;
      elseif( in_array($input['value'][0]['tz']{0}, array( '+', '-' )) &&
               ctype_digit( substr( $input['value'][0]['tz'], 1 )))
        $dummy = TRUE;
      elseif( ctype_digit( $input['value'][0]['tz'] ))
        $dummy = TRUE;
      elseif( isset( $input['value'][0]['tz'] )) {
        $input['params']['TZID'] = $input['value'][0]['tz'];
        foreach( $input['value'] as $eix => $inputa ) {
          if( !empty( $input['value'][0]['tz'] )   &&
               ( $input['value'][0]['tz'] != 'Z' ) &&
            ( !( in_array( $input['value'][0]['tz']{0}, array( '+', '-' )) &&
                 ctype_digit( substr( $input['value'][0]['tz'], 1 ))) &&
              !ctype_digit( $input['value'][0]['tz'] ) ) )
            unset( $input['value'][$eix]['tz'] );
        }
      }
      elseif( isset( $input['params']['TZID'] ))
        unset( $input['params']['TZID'] );

      $this->rdate[] = $input;
 //    echo 'setRdate ut 2 '; print_r ( $input ); echo "<br />\n"; // test ##
    }
  }
211343
public function getMysqlDateFormat($dateFormat = NULL) {
        if(is_null($dateFormat)) {
            $dateFormat = $this->getCurrentFormat();
        }
        switch($dateFormat) {
            case self::DATE_FORMAT_UK:
                return '%d/%m/%Y';
                break;
            case self::DATE_FORMAT_US:
                return '%m/%d/%Y';
                break;
            case self::DATE_FORMAT_EURO:
                return '%d-%m-%Y';
                break;
            default:
                throw new InvalidArgumentException('Unexpected Date Format: ' . $dateFormat);
                break;
        }
    }
1298472
public static function checkFormat($strDate, $strFormat)
    {
        $objDate = \DateTime::createFromFormat($strFormat, $strDate);
        return $objDate && $objDate->format($strFormat) === $strDate;
    }
277430
function generateLocaleExtra(locale, localeData) {
  const dayPeriods = getDayPeriodsNoAmPm(localeData);
  const dayPeriodRules = getDayPeriodRules(localeData);

  let dayPeriodsSupplemental = [];

  if (Object.keys(dayPeriods.format.narrow).length) {
    const keys = Object.keys(dayPeriods.format.narrow);

    if (keys.length !== Object.keys(dayPeriodRules).length) {
      throw new Error(`Error: locale ${locale} has not the correct number of day period rules`);
    }

    const dayPeriodsFormat = removeDuplicates([
      objectValues(dayPeriods.format.narrow),
      objectValues(dayPeriods.format.abbreviated),
      objectValues(dayPeriods.format.wide)
    ]);

    const dayPeriodsStandalone = removeDuplicates([
      objectValues(dayPeriods['stand-alone'].narrow),
      objectValues(dayPeriods['stand-alone'].abbreviated),
      objectValues(dayPeriods['stand-alone'].wide)
    ]);

    const rules = keys.map(key => dayPeriodRules[key]);

    dayPeriodsSupplemental = [...removeDuplicates([dayPeriodsFormat, dayPeriodsStandalone]), rules];
  }

  return `${HEADER}
const u = undefined;

export default ${stringify(dayPeriodsSupplemental).replace(/undefined/g, 'u')};
`;
}
278166
public static function localDateTime() : PatternParser
    {
        static $parser;

        if ($parser) {
            return $parser;
        }

        return $parser = (new PatternParserBuilder())
            ->append(self::localDate())
            ->appendLiteral('T')
            ->append(self::localTime())
            ->toParser();
    }
709347
public static function format($pDate, $pFormat = 'short')
    {
    	switch ($pFormat) {
    		case 'short':
    			return strftime('%x', strtotime($pDate));
    			break;
    		case 'long':
    			return strftime('%x %H:%M', strtotime($pDate));
    			break;
    		case 'full':
    			return strftime('%x %H:%M:%S', strtotime($pDate));
    			break;
    	}

    	throw new Exception("The requested date format is not correct");
    }
1032761
public static function formatDate($firstDate, $secondDate = null, $returnAsArray = false)
    {
        if ($firstDate instanceof \DateTime) {
            $firstTimestamp = $firstDate->format('U');
        } elseif (is_int($firstDate)) {
            $firstTimestamp = strtotime($firstDate);
        } else {
            $firstTimestamp = strtotime($firstDate);
        }

        $secondTimestamp = null;
        if ($secondDate instanceof \DateTime) {
            $secondTimestamp = $secondDate->format('U');
        } elseif (is_int($secondDate)) {
            $secondTimestamp = strtotime($secondDate);
        } else {
            $secondTimestamp = strtotime($secondDate);
        }

        return self::formatTimestamp($firstTimestamp, $secondTimestamp, $returnAsArray);
    }
505273
public static function getDate($time = 'now', $tzOffset = null)
	{
		static $classname;
		static $mainLocale;

		$language = self::getLanguage();
		$locale = $language->getTag();

		if (!isset($classname) || $locale != $mainLocale)
		{
			// Store the locale for future reference
			$mainLocale = $locale;

			if ($mainLocale !== false)
			{
				$classname = str_replace('-', '_', $mainLocale) . 'Date';

				if (!class_exists($classname))
				{
					// The class does not exist, default to JDate
					$classname = 'Date';
				}
			}
			else
			{
				// No tag, so default to JDate
				$classname = 'Date';
			}
		}

		$key = $time . '-' . ($tzOffset instanceof DateTimeZone ? $tzOffset->getName() : (string) $tzOffset);

		if (!isset(self::$dates[$classname][$key]))
		{
			self::$dates[$classname][$key] = new $classname($time, $tzOffset);
		}

		$date = clone self::$dates[$classname][$key];

		return $date;
	}