/** * @test * it should restore system timezone after operations */ public function it_should_restore_system_timezone_after_operations() { $system_timezone = 'America/New_York'; date_default_timezone_set($system_timezone); $wp_timezone = 'Europe/Rome'; update_option('timezone_string', $wp_timezone); $sut = new DST(strtotime('November 1st, 2015')); $sut->is_in_dst(); $this->assertEquals('America/New_York', date_default_timezone_get()); }
/** * Returns the time of the object aligned with another date object. * * If both in date or both not in DST the same time; if this time is in DST and the * target date is not in DST then the time +1hr, else the time -1 hr. * * @param Tribe__Events__Utils__DST $dst Another DST object this one should be aligned with. * * @return int The DST aligned UNIX timestamp. */ public function get_time_aligned_with(Tribe__Events__Utils__DST $dst) { $dst_aligned = $this->is_in_dst() == $dst->is_in_dst(); $offset = $dst->is_in_dst() - $this->is_in_dst(); return $dst_aligned ? $this->time : $this->time + $offset * 3600; }