Browse Source

Fix missing slash

Joachim M. Giæver 4 years ago
parent
commit
689099934e
4 changed files with 16 additions and 4 deletions
  1. 1 1
      composer.json
  2. 5 0
      index.php
  3. 8 0
      src/Yr/Forecast/Tabular.php
  4. 2 3
      src/Yr/Forecast/Tabular/Statistics.php

+ 1 - 1
composer.json

@@ -6,7 +6,7 @@
     "license": "MIT",
     "authors": [{
         "name": "Joachim M. Giaever",
-        "email": "joachi[]giaever.org"
+        "email": "joachim[]giaever.org"
     }],
     "autoload": {
         "psr-4": {

+ 5 - 0
index.php

@@ -11,6 +11,11 @@ $range = $forecast->getTabular()->getBetween(
 );
 
 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");
 }

+ 8 - 0
src/Yr/Forecast/Tabular.php

@@ -89,6 +89,14 @@ class Tabular implements \IteratorAggregate {
         return $n;
     }
 
+    public function getFrom(): \DateTimeInterface {
+        return current($this->time)->getFrom();
+    }
+
+    public function getUntil(): \DateTimeInterface {
+        return current(array_reverse($this->time))->getUntil();
+    }
+
     /**
      * {@inheritDoc}
      */

+ 2 - 3
src/Yr/Forecast/Tabular/Statistics.php

@@ -94,10 +94,9 @@ class Statistics {
            if ($s != null && $s['avg'] != 0)
                return $this->symbol;
 
-        $this->symbol = array_map(function(array $symbol) {
+        array_walk($this->symbol, function(array &$symbol) {
             $symbol['avg'] = new CustomUnit($symbol['count'] / $this->count * 100, '%');
-            return $symbol;
-        }, $this->symbol);
+        });
 
         usort($this->symbol, function(array $a, array $b) {
             return (int)($a['avg']->sub($b['avg']))->getValue();