/** * @test */ public function itBringsThePreviousMonthFromMarchTheLast() { // Arrange $reference_date = new \DateTime('2013-03-31'); // Act $previous_month = DatesTransformer::previousMonth($reference_date); // Assert $this->assertEquals('2013-02', $previous_month->format('Y-m')); }
/** * @Template */ public function listByMonthAction($year, $month) { $day = new \DateTime("{$year}-{$month}-01"); $events = $this->getCalendar()->findAllByMonth($day); $collection = new EventCollection($events); return array('events' => $collection, 'dates' => $this->getCalendar()->getMonthSheetDays($day), 'current' => $day, 'next' => DatesTransformer::nextMonth($day), 'previous' => DatesTransformer::previousMonth($day)); }
public function listByUserAction($year, $month, $user) { $day = new \DateTime("{$year}-{$month}-01"); $events = $this->getDoctrine()->getRepository('PortailCalendarBundle:Event')->findAllByMonth($user, $day); $collection = new EventCollection($events); return $this->render('PortailRendezvousBundle::listByUser.html.twig', array('events' => $collection, 'dates' => $this->getCalendar()->getMonthSheetDays($day), 'current' => $day, 'next' => DatesTransformer::nextMonth($day), 'previous' => DatesTransformer::previousMonth($day))); }