/**
  * Given a unix time, return a human-readable version.
  *
  * @param mixed $unixTime The given unix time.
  *
  * @return string A human readable time.
  */
 protected final function unixTimeToHumanReadable($unixTime)
 {
     if ($unixTime == '') {
         return '';
     }
     $context = tubepress_impl_patterns_sl_ServiceLocator::getExecutionContext();
     if ($context->get(tubepress_api_const_options_names_Meta::RELATIVE_DATES)) {
         return tubepress_impl_util_TimeUtils::getRelativeTime($unixTime);
     }
     return @date($context->get(tubepress_api_const_options_names_Meta::DATEFORMAT), $unixTime);
 }
 /**
  * Build a map of attribute names => attribute values for the video construction event.
  *
  * @param tubepress_api_event_EventInterface $event The video construction event.
  *
  * @return array An associative array of attribute names => attribute values
  */
 protected final function buildAttributeMap(tubepress_api_event_EventInterface $event)
 {
     $toReturn = array();
     $index = $event->getArgument('zeroBasedFeedIndex');
     $videoArray = $event->getArgument('videoArray');
     /* Author */
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_AUTHOR_DISPLAY_NAME] = $videoArray[$index]->owner->display_name;
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_AUTHOR_USER_ID] = $videoArray[$index]->owner->username;
     /* Description */
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_DESCRIPTION] = $this->trimDescription($videoArray[$index]->description);
     /* Duration */
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_DURATION_SECONDS] = $videoArray[$index]->duration;
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_DURATION_FORMATTED] = tubepress_impl_util_TimeUtils::secondsToHumanTime($toReturn[tubepress_api_video_Video::ATTRIBUTE_DURATION_SECONDS]);
     /* Home URL */
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_HOME_URL] = 'http://vimeo.com/' . $videoArray[$index]->id;
     /* ID */
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_ID] = $videoArray[$index]->id;
     /* Keywords */
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_KEYWORD_ARRAY] = $this->_gatherArrayOfContent($videoArray[$index], 'tags', 'tag');
     /* Likes. */
     if (isset($videoArray[$index]->number_of_likes)) {
         $toReturn[tubepress_api_video_Video::ATTRIBUTE_LIKES_COUNT] = $videoArray[$index]->number_of_likes;
     }
     /* Thumbnail. */
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_THUMBNAIL_URL] = $this->_getThumbnailUrl($videoArray, $index);
     /* Time published. Vimeo dates are in US Eastern Time.*/
     $reset = date_default_timezone_get();
     date_default_timezone_set('America/New_York');
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_TIME_PUBLISHED_UNIXTIME] = strtotime($videoArray[$index]->upload_date);
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_TIME_PUBLISHED_FORMATTED] = $this->unixTimeToHumanReadable($toReturn[tubepress_api_video_Video::ATTRIBUTE_TIME_PUBLISHED_UNIXTIME]);
     date_default_timezone_set($reset);
     /* Title. */
     $toReturn[tubepress_api_video_Video::ATTRIBUTE_TITLE] = $videoArray[$index]->title;
     /* Views. */
     if (isset($videoArray[$index]->number_of_plays)) {
         $toReturn[tubepress_api_video_Video::ATTRIBUTE_VIEW_COUNT] = number_format($videoArray[$index]->number_of_plays);
     }
     return $toReturn;
 }
 private function _getTimePublishedUnixTime(DOMXPath $xpath, $index)
 {
     $publishedNode = $this->_relativeQuery($xpath, $index, 'media:group/yt:uploaded');
     if ($publishedNode->length == 0) {
         return '';
     }
     $rawTime = $publishedNode->item(0)->nodeValue;
     return tubepress_impl_util_TimeUtils::rfc3339toUnixTime($rawTime);
 }