/** * Converts the specified local date-time to the local date-time actually * seen on a wall clock. * <p> * This method converts using the type of this enum. * The output is defined relative to the 'before' offset of the transition. * <p> * The UTC type uses the UTC offset. * The STANDARD type uses the standard offset. * The WALL type returns the input date-time. * The result is intended for use with the wall-offset. * * @param LocalDateTime $dateTime the local date-time, not null * @param ZoneOffset $standardOffset the standard offset, not null * @param ZoneOffset $wallOffset the wall offset, not null * @return LocalDateTime the date-time relative to the wall/before offset, not null */ public function createDateTime(LocalDateTime $dateTime, ZoneOffset $standardOffset, ZoneOffset $wallOffset) { switch ($this->val) { case 0: $difference = $wallOffset->getTotalSeconds() - ZoneOffset::UTC()->getTotalSeconds(); return $dateTime->plusSeconds($difference); case 2: $difference = $wallOffset->getTotalSeconds() - $standardOffset->getTotalSeconds(); return $dateTime->plusSeconds($difference); default: // WALL return $dateTime; } }
/** * Returns a copy of this {@code OffsetDateTime} with the specified number of seconds added. * <p> * This instance is immutable and unaffected by this method call. * * @param int $seconds the seconds to add, may be negative * @return OffsetDateTime an {@code OffsetDateTime} based on this date-time with the seconds added, not null * @throws DateTimeException if the result exceeds the supported date range */ public function plusSeconds($seconds) { return $this->_with($this->dateTime->plusSeconds($seconds), $this->offset); }
/** * Gets the local transition date-time, as would be expressed with the 'after' offset. * <p> * This is the first date-time after the discontinuity, when the new offset applies. * <p> * The combination of the 'before' date-time and offset represents the same instant * as the 'after' date-time and offset. * * @return LocalDateTime the transition date-time expressed with the after offset, not null */ public function getDateTimeAfter() { return $this->transition->plusSeconds($this->getDurationSeconds()); }
/** * Returns a copy of this {@code ZonedDateTime} with the specified number of seconds added. * <p> * This operates on the instant time-line, such that adding one second will * always be a duration of one second later. * This may cause the local date-time to change by an amount other than one second. * Note that this is a different approach to that used by days, months and years. * <p> * This instance is immutable and unaffected by this method call. * * @param int $seconds the seconds to add, may be negative * @return ZonedDateTime a {@code ZonedDateTime} based on this date-time with the seconds added, not null * @throws DateTimeException if the result exceeds the supported date range */ public function plusSeconds($seconds) { return $this->resolveInstant($this->dateTime->plusSeconds($seconds)); }