/** * {@inheritdoc} */ public function generateSnapshots(Response $response, $url) { $start = \DateTime::createFromFormat('U', mktime(0, 0, 0, 1, 1, $this->year)); $snapshots = new SnapshotCollection($start, $start->add(new \DateInterval('P1Y'))); foreach ($this->getDates($response) as $date) { $snapshot = new Snapshot($date, self::BASE_URL . sprintf('%s/%s', $date->format('YmdHis'), $url)); $snapshots->getSnapshots()->append($snapshot); } return $snapshots; }
/** * {@inheritdoc} */ public function generateSnapshots(Response $response, $url) { $dates = $this->getMetaData($response); if (!$dates) { return null; } $snapshots = new SnapshotCollection(current($dates)->getDate(), end($dates)->getDate()); $snapshots->getSnapshots()->exchangeArray($dates); return $snapshots; }
public function testGetPeriod() { $sc = new SnapshotCollection(new \DateTime('12-12-2013'), new \DateTime('20-12-2013')); $this->assertInstanceOf('DatePeriod', $sc->getPeriod()); $day = 0; foreach ($sc->getPeriod() as $date) { $day++; } // count days between start and end date included $this->assertEquals(9, $day); }