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


PHP Utilities::dateFromOffset方法代码示例

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


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

示例1: loadShowtimes

 /**
  * @param GeocodeCached $geocode Previously stored geoLocation information
  * @param string $currentDate date for showtimes to load, advisable to pass it in
  * @param int $dateOffset number of days from the current dates
  * @return TheatreData[] an array of schema TheatreData, see below for description
  *
  * Organized in the format =>
  *
  * ```
  *
  *  TheatreData : [
  *      'theatre' => [
  *              ...fields from theatre table, MUST contain name and address...,
  *      ]
  *      'movies' => MovieData[]
  *  ]
  *
  * MovieData : [
  *     'movie' => [
  *          ...fields from movie table, MUST contain title...,
  *     ]
  *     'showtimes' => ShowtimeData[]
  * ]
  *
  * ShowtimeData: [
  *      ...fields from showtime table, must conatin show_date, show_time & type...
  * ]
  * ```
  */
 public function loadShowtimes(GeocodeCached $geocode, $currentDate = null, $dateOffset = 0)
 {
     $params = ['country' => $geocode->country_iso, 'event_date' => \Utilities::dateFromOffset($currentDate ?: date('Y-m-d'), $dateOffset)];
     \SystemLogger::debug('Begining API Request to Tripican');
     $start = microtime(true);
     $allCinemaMovieShowtimes = TripicanDataLoader::GetCinemaMovieShowtimes($this->apiClient, $params);
     \SystemLogger::debug('Request to API completed in :', microtime(true) - $start);
     $theatres = [];
     foreach ($allCinemaMovieShowtimes as $cinemaMovieShowtimes) {
         $theatre = $cinemaMovieShowtimes['cinema'];
         $id = $theatre['id'];
         if (!isset($theatres[$id])) {
             $theatres[$id] = ['theatre' => ['name' => $theatre['centre_name'], 'address' => $this->_getAddress($theatre), 'longitude' => $theatre['place']['long'], 'latitude' => $theatre['place']['lat']], 'movies' => []];
         }
         $theatreData =& $theatres[$id];
         foreach ($cinemaMovieShowtimes['movie_showtimes'] as $movieShowtimes) {
             $movie = $movieShowtimes['movie'];
             $mId = $movie['id'];
             if (!isset($theatreData['movies'][$mId])) {
                 $theatreData['movies'][$mId] = ['movie' => ['title' => $movie['title'], 'genre' => $movie['genre'][0], 'user_rating' => isset($movie['imdb_rating']) ? floatval($movie['imdb_rating'][0] / 10.0) : null, 'poster_url' => $movie['poster'], 'rated' => $movie['rated'][0], 'runtime' => $movie['duration']], 'showtimes' => []];
             }
             $movieData =& $theatreData['movies'][$mId];
             foreach ($movieShowtimes['showtimes'] as $showtime) {
                 $movieData['showtimes'][] = ['show_date' => $showtime['event_date'], 'show_time' => $showtime['event_time'], 'type' => $this->_getMapType($showtime['type']), 'url' => $showtime['online_ticketing'] ? $showtime['url'] : null];
             }
         }
     }
     array_walk($theatres, function (&$t) {
         $t['movies'] = array_values($t['movies']);
     });
     if (!empty($theatres)) {
         $this->overrideDistanceCompute();
     }
     return array_values($theatres);
 }
开发者ID:logbon72,项目名称:pebble-movies-server,代码行数:64,代码来源:Tripican.php

示例2: loadShowtimes

 public function loadShowtimes(GeocodeCached $geocode, $currentDate = null, $dateOffset = 0)
 {
     \SystemLogger::debug('SCRAPING started');
     $data = ['countryIso' => $geocode->country_iso, 'date' => \Utilities::dateFromOffset($currentDate ?: date('Y-m-d'), $dateOffset), 'postalCode' => urlencode($geocode->postal_code)];
     $pageData = $this->callUrl($this->formatUrl($this->urlTemplate, $data, true));
     //$pageData = file_get_contents(__DIR__ . DS . "showtimes.html");
     //file_put_contents("data_".microtime(true).".html", $pageData);
     $this->currentDate = $data['date'];
     return $this->extractShowtimes($pageData);
 }
开发者ID:logbon72,项目名称:pebble-movies-server,代码行数:10,代码来源:IMDBScraper.php

示例3: loadShowtimes

 public function loadShowtimes(GeocodeCached $geocode, $currentDate = null, $dateOffset = 0)
 {
     $this->currentDate = \Utilities::dateFromOffset($currentDate, $dateOffset);
     $allCinemasFound = array();
     for ($i = 0; $i < self::MAX_PAGES; $i++) {
         $data = array('latlng' => $geocode->getGeocode(), 'date' => $dateOffset, 'start' => $i * self::PER_PAGE);
         $url = $this->formatUrl($this->showtimesUrl, $data, true);
         $pageData = $this->callUrl($url);
         //test if hasNextPage===
         $totalFound = count($allCinemasFound);
         $totalPages = 0;
         $allCinemasFound = array_merge($allCinemasFound, $this->extractTheatreMovieShowtimes($pageData, ShowtimeService::THEATRE_LIMIT - $totalFound, $totalPages));
         \SystemLogger::info("Total pages: ", $totalPages);
         if ($i >= $totalPages - 1) {
             break;
         }
     }
     return $allCinemasFound;
 }
开发者ID:logbon72,项目名称:pebble-movies-server,代码行数:19,代码来源:GoogleMovies.php


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