/** * @covers ilRoomSharingDateUtils::getPrintedDateTime */ public function testGetPrintedDateTime() { $expected1 = "test., 31. test 2010, 14:02"; $actual1 = UTILS::getPrintedDateTime(new DateTime("2010-12-31 14:02:02")); $this->assertEquals($expected1, $actual1); $expected2 = "test., 01. test 2015, 15:02"; $actual2 = UTILS::getPrintedDateTime(new DateTime("2015-02-29 15:02:02")); $this->assertEquals($expected2, $actual2); $expected3 = "test., 29. test 2016, 16:02"; $actual3 = UTILS::getPrintedDateTime(new DateTime("2016-02-29 16:02:02")); $this->assertEquals($expected3, $actual3); }
/** * Reads the date of the booking and converts it into a printed version. * * @param array $a_bookingData * * @return string Date */ public static function readBookingDate($a_bookingData) { $date_from = DateTime::createFromFormat("Y-m-d H:i:s", $a_bookingData['date_from']); $date_to = DateTime::createFromFormat("Y-m-d H:i:s", $a_bookingData['date_to']); $date = ilRoomSharingDateUtils::getPrintedDateTime($date_from); $date .= " - "; // Check whether the date_from differs from the date_to if (!ilRoomSharingDateUtils::isEqualDay($date_from, $date_to)) { //Display the date_to in the next line $date .= '<br>'; $date .= ilRoomSharingDateUtils::getPrintedDate($date_to); $date .= ', '; } $date .= ilRoomSharingDateUtils::getPrintedTime($date_to); return $date; }