public function testGetMondayFromDate() { $nativeDate = new \DateTime('now'); $this->assertStringEndsNotWith('00:00:00+0000', $nativeDate->format(\DateTime::ISO8601)); $monday = Calendar::monday($nativeDate); $this->assertEquals($monday->format('w'), 1); $this->assertStringEndsWith('00:00:00.000000+0000', $monday->toIsoString()); $date = new DateTime('now'); $this->assertStringEndsNotWith('00:00:00.000000+0000', $date->toIsoString()); $monday = Calendar::monday($date); $this->assertEquals($monday->format('w'), 1); $this->assertStringEndsWith('00:00:00.000000+0000', $monday->toIsoString()); }
public function testDateBeforeUnixTime() { $date = DateTime::createFromFormat('d.m.Y u', '06.06.1799 654321'); $nativeDate = $date->asNativeDate(); $this->assertNotFalse($nativeDate); $this->assertNotFalse($date->asDate()); $this->assertEquals($date->format(DateTime::FULL_ISO8601), $nativeDate->format(DateTime::FULL_ISO8601)); }
public function testFormatToIso() { $date = DateTime::createFromFormat('U.u', (string) microtime(true)); $this->assertStringEndsNotWith('.000000+0000', $date->toIsoString()); }