1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- require __DIR__ . '/vendor/autoload.php';
- $url = 'https://www.yr.no/place/Norway/Troms/Tromsø/Tromsø/forecast_hour_by_hour.xml';
- $forecast = new App\Yr\Forecast($url);
- $range = $forecast->getTabular()->getBetween(
- $forecast->getSunset(), $forecast->getSunrise()->add(new \DateInterval('P1D'))
- );
- echo '<pre>';
- echo sprintf("Forecast from %s until %s, updated %s:\n",
- $range->getFrom()->format('d.m H:i'),
- $range->getUntil()->format('d.m H:i'),
- $forecast->getLastUpdate()->format('H:i')
- );
- foreach ($range->getVariations()->getData() as $data) {
- echo $data['time']->getFrom()->format("H:i");
- }
- //echo sprintf("%s: %s\n", $data['time']->getFrom()->format("H:i"), join(", ", $data['entities']));
- $f = current(iterator_to_array($range->getIterator()));
- echo $f->getWindSpeed()->convertTo('ft/s');
- echo "\n";
- $stat = $range->getStatistics();
- echo "\n";
- echo $stat->getAverageTemperature();
- echo "\n";
- echo $stat->getAverageWindSpeed();
- echo "\n";
- var_dump($stat->getAverageSymbols());
- var_dump($stat->getMostCommonSymbol());
- echo "\n";
- foreach ($forecast->getCredit() as $c)
- echo $c . "\n";
- ?>
|