/** * @covers ilRoomSharingDateUtils::isEqualDay */ public function testIsEqualDay() { $this->assertTrue(UTILS::isEqualDay(new DateTime("2010-12-31 14:02:02"), new DateTime("2010-12-31 14:02:02"))); $this->assertFalse(UTILS::isEqualDay(new DateTime("2010-11-30 14:02:02"), new DateTime("2011-12-30 14:02:02"))); $this->assertFalse(UTILS::isEqualDay(new DateTime("2010-11-30 14:02:02"), new DateTime("2010-12-30 14:02:02"))); $this->assertFalse(UTILS::isEqualDay(new DateTime("2010-12-30 14:02:02"), new DateTime("2010-12-31 14:02:02"))); $this->assertTrue(UTILS::isEqualDay(new DateTime("2016-02-29 14:02:02"), new DateTime("2016-02-29 14:02:02"))); $this->assertTrue(UTILS::isEqualDay(new DateTime("2014-02-29 14:02:02"), new DateTime("2014-02-29 14:02:02"))); $this->assertFalse(UTILS::isEqualDay(new DateTime("2015-02-29 14:02:02"), new DateTime("2016-02-29 14:02:02"))); }
/** * 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; }