Timezone support for openingTimes
parent
2eeb41df45
commit
24c415fbaa
|
@ -3,6 +3,8 @@
|
||||||
namespace level2;
|
namespace level2;
|
||||||
|
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
|
use \DateTime;
|
||||||
|
use \DateTimeZone;
|
||||||
|
|
||||||
class Level2 {
|
class Level2 {
|
||||||
|
|
||||||
|
@ -223,6 +225,7 @@
|
||||||
static public function getChartData( $app ) {
|
static public function getChartData( $app ) {
|
||||||
|
|
||||||
$dowMap = array( 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' );
|
$dowMap = array( 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' );
|
||||||
|
$localtime_offset = date('Z') / 3600;
|
||||||
|
|
||||||
$chartDataQuery = 'SELECT ROUND( AVG( people ) )
|
$chartDataQuery = 'SELECT ROUND( AVG( people ) )
|
||||||
FROM state
|
FROM state
|
||||||
|
@ -235,8 +238,7 @@
|
||||||
$chartDataByDay[ 'name' ] = $dowMap[ $dow ];
|
$chartDataByDay[ 'name' ] = $dowMap[ $dow ];
|
||||||
|
|
||||||
for( $hod = 0; $hod < 24; $hod++ ) {
|
for( $hod = 0; $hod < 24; $hod++ ) {
|
||||||
|
$chartDataByDay[ 'data' ][ ($hod + $localtime_offset) % 24 ] = $app[ 'db' ]->fetchColumn(
|
||||||
$chartDataByDay[ 'data' ][ $hod ] = $app[ 'db' ]->fetchColumn(
|
|
||||||
$chartDataQuery,
|
$chartDataQuery,
|
||||||
array(
|
array(
|
||||||
$dow,
|
$dow,
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
{% for day in chart %}
|
{% for day in chart %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">{{ day.name }}</th>
|
<th scope="row">{{ day.name }}</th>
|
||||||
{% for value in day.data %}
|
{% for hour in 0..23 %}
|
||||||
<td>{{ value }}</td>
|
<td>{{ day.data[hour] }}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in New Issue