Created
July 3, 2013 21:41
-
-
Save catcherdev/5923091 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//each $event is an SS ArrayDatas | |
foreach($events as $event) { | |
$startDateTime = strtotime($event->startDateTime); | |
$startDate = date('D, m/d', $startDateTime); | |
$event->startTime = $startTime = date('h:i A', $startDateTime); | |
$event->endTime = $endTime = date('h:i A', strtotime($event->endDateTime)); | |
if(!array_key_exists($startDate, $EventsByDate)) { | |
$EventsByDate[$startDate] = new ArrayData(array("StartDate" => $startDate, | |
"EventsByTime" => new ArrayList())); | |
} | |
$times = $EventsByDate[$startDate]->EventsByTime->column('StartTime'); | |
if(!in_array($startTime, $times)){ | |
$EventsByDate[$startDate]->EventsByTime->push(new ArrayData(array("StartTime" => $startTime, | |
"EndTime" => $endTime, | |
"Events" => new ArrayList()))); | |
} | |
$eventsByTime = $EventsByDate[$startDate]->EventsByTime->filter('StartTime', $startTime)->first(); | |
$eventsByTime->Events->push($event); | |
} | |
$EventsByDateList = new ArrayList($EventsByDate); | |
return $this->Customise(array('EventsByDate' => $EventsByDateList)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment