aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/config.php4
-rw-r--r--lib/program.php34
2 files changed, 32 insertions, 6 deletions
diff --git a/lib/config.php b/lib/config.php
index 88181b9..06516ef 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -4,10 +4,10 @@ date_default_timezone_set('Europe/Berlin');
// guessed automatically
// $GLOBALS['CONFIG']['baseurl'] = 'http://foo.com/bar/';
-$GLOBALS['CONFIG']['SCHEDULE'] = 'http://fahrplan.mrmcd.net/schedule.xml';
+$GLOBALS['CONFIG']['SCHEDULE'] = 'https://fiffkon.de/app/schedule.xml';
$GLOBALS['CONFIG']['SCHEDULE_CACHE_TTL'] = 5;
$GLOBALS['CONFIG']['SCHEDULE_SCALE'] = 0.2; // float, px per second
-$GLOBALS['CONFIG']['SCHEDULE_OFFSET'] = strtotime('2014-11-06T17:00:00+01:00') - strtotime('2014-09-05T17:00:00+02:00');
+$GLOBALS['CONFIG']['SCHEDULE_OFFSET'] = 0;//strtotime('2014-11-06T17:00:00+01:00') - strtotime('2014-09-05T17:00:00+02:00');
$GLOBALS['CONFIG']['ROOMS'] = array(
diff --git a/lib/program.php b/lib/program.php
index c134b8e..b599f9c 100644
--- a/lib/program.php
+++ b/lib/program.php
@@ -2,19 +2,45 @@
function program()
{
- $cacheidx = __FILE__.':'.__FUNCTION__.':program';
+ $cacheidx = __FILE__.':'.__FUNCTION__.':program:'.$GLOBALS['CONFIG']['SCHEDULE'];
if(function_exists('apc_fetch') && $program = apc_fetch($cacheidx))
return $program;
$program = array();
$schedule = simplexml_load_file($GLOBALS['CONFIG']['SCHEDULE']);
+ // re-calculate day-ends
+ // some schedules have long gaps before the first talk or talks that expand beyond the dayend
+ // (fiffkon, i look at you)
+ // so to be on the safer side we calculate our own daystart/end here
+ foreach($schedule->day as $day)
+ {
+ $daystart = PHP_INT_MAX;
+ $dayend = 0;
+
+ foreach($day->room as $room)
+ {
+ foreach($room->event as $event)
+ {
+ $start = strtotime((string)$event->date);
+ $duration = strtoduration((string)$event->duration);
+ $end = $start + $duration;
+
+ $daystart = min($daystart, $start);
+ $dayend = max($dayend, $end);
+ }
+ }
+
+ $day['start'] = $daystart;
+ $day['end'] = $dayend;
+ }
+
$dayidx = 0;
foreach($schedule->day as $day)
{
$dayidx++;
- $daystart = strtotime((string)$day['start']);
- $dayend = strtotime((string)$day['end']);
+ $daystart = (int)$day['start'];
+ $dayend = (int)$day['end'];
$roomidx = 0;
foreach($day->room as $room)
@@ -23,7 +49,7 @@ function program()
$name = (string)$room['name'];
$lastend = false;
- foreach ($room->event as $event)
+ foreach($room->event as $event)
{
$start = strtotime((string)$event->date);
$duration = strtoduration((string)$event->duration);