Timezone support for openingTimes

master
defane 2015-12-14 22:04:34 +01:00
parent 2eeb41df45
commit 24c415fbaa
2 changed files with 6 additions and 4 deletions

View File

@ -3,6 +3,8 @@
namespace level2;
use Silex\Application;
use \DateTime;
use \DateTimeZone;
class Level2 {
@ -223,6 +225,7 @@
static public function getChartData( $app ) {
$dowMap = array( 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' );
$localtime_offset = date('Z') / 3600;
$chartDataQuery = 'SELECT ROUND( AVG( people ) )
FROM state
@ -235,8 +238,7 @@
$chartDataByDay[ 'name' ] = $dowMap[ $dow ];
for( $hod = 0; $hod < 24; $hod++ ) {
$chartDataByDay[ 'data' ][ $hod ] = $app[ 'db' ]->fetchColumn(
$chartDataByDay[ 'data' ][ ($hod + $localtime_offset) % 24 ] = $app[ 'db' ]->fetchColumn(
$chartDataQuery,
array(
$dow,

View File

@ -18,8 +18,8 @@
{% for day in chart %}
<tr>
<th scope="row">{{ day.name }}</th>
{% for value in day.data %}
<td>{{ value }}</td>
{% for hour in 0..23 %}
<td>{{ day.data[hour] }}</td>
{% endfor %}
</tr>
{% endfor %}