Repository: microsoft/gctoolkit
File: api/src/main/java/com/microsoft/gctoolkit/time/DateTimeStamp.java (Java)

Code before:
    }

    /**
     * Return a new {@code DateTimeStamp} resulting from adding the
     * decimal second offset to this.
     * @param offsetInDecimalSeconds An offset, in decimal seconds.
     * @return A new {@code DateTimeStamp}, {@code offsetInDecimalSeconds} from this.
     */
    public DateTimeStamp add(double offsetInDecimalSeconds) {
        if (Double.isNaN(offsetInDecimalSeconds))
            throw new IllegalArgumentException("Cannot add " + Double.NaN);

        double adjustedTimeStamp = Double.NaN;
        ZonedDateTime adjustedDateStamp = null;
        if ( hasTimeStamp()) {
            adjustedTimeStamp = getTimeStamp() + offsetInDecimalSeconds;
        }

        if (hasDateStamp()) {
            double offset = (Double.isNaN(offsetInDecimalSeconds)) ? 0.000d : offsetInDecimalSeconds;
            int seconds = (int) offset;
            long nanos = ((long) ((offset % 1) * 1_000L)) * 1_000_000L;
            adjustedDateStamp = dateTime.plusSeconds(seconds).plusNanos(nanos);
        }

            return new DateTimeStamp(adjustedDateStamp,adjustedTimeStamp);
    }

    /**
     * Return a new {@code DateTimeStamp} resulting from subtracting the
     * decimal second offset from this.
     * @param offsetInDecimalSeconds An offset, in decimal seconds.
     * @return A new {@code DateTimeStamp}, {@code offsetInDecimalSeconds} from this.
     */
    public DateTimeStamp minus(double offsetInDecimalSeconds) {
        return add(-offsetInDecimalSeconds);
    }

    /**
     * Return the difference between this time stamp, and the time stamp of
     * the other DateTimeStamp.
     * @param other The other {@code DateTimeStamp}
     * @return The difference between this time stamp, and the time stamp
     * of the other DateTimeStamp.
     */
    public double minus(DateTimeStamp other) {
        if (hasTimeStamp() && other.hasTimeStamp())
            return getTimeStamp() - other.getTimeStamp();
        if (hasDateStamp() && other.hasDateStamp()) {
            double thisInSeconds = (double)getDateTime().toEpochSecond() + ((double)(getDateTime().getNano() / 1_000_000)) / 1000.0d;
            double otherInSeconds = (double)other.getDateTime().toEpochSecond() + ((double)(other.getDateTime().getNano() / 1_000_000)) / 1000.0d;

Review comment (suggestion):
```suggestion
            return new DateTimeStamp(adjustedDateStamp, adjustedTimeStamp);
```

Code after:

    /**
     * Return a new {@code DateTimeStamp} resulting from adding the
     * decimal second offset to this.
     * @param offsetInDecimalSeconds An offset, in decimal seconds.
     * @return A new {@code DateTimeStamp}, {@code offsetInDecimalSeconds} from this.
     */
    public DateTimeStamp add(double offsetInDecimalSeconds) {
        if (Double.isNaN(offsetInDecimalSeconds))
            throw new IllegalArgumentException("Cannot add " + Double.NaN);

        double adjustedTimeStamp = Double.NaN;
        ZonedDateTime adjustedDateStamp = null;
        if ( hasTimeStamp()) {
            adjustedTimeStamp = getTimeStamp() + offsetInDecimalSeconds;
        }

        if (hasDateStamp()) {
            double offset = (Double.isNaN(offsetInDecimalSeconds)) ? 0.000d : offsetInDecimalSeconds;
            int seconds = (int) offset;
            long nanos = ((long) ((offset % 1) * 1_000L)) * 1_000_000L;
            adjustedDateStamp = dateTime.plusSeconds(seconds).plusNanos(nanos);
        }

        return new DateTimeStamp(adjustedDateStamp, adjustedTimeStamp);
    }

    /**
     * Return a new {@code DateTimeStamp} resulting from subtracting the
     * decimal second offset from this.
     * @param offsetInDecimalSeconds An offset, in decimal seconds.
     * @return A new {@code DateTimeStamp}, {@code offsetInDecimalSeconds} from this.
     */
    public DateTimeStamp minus(double offsetInDecimalSeconds) {
        return add(-offsetInDecimalSeconds);
    }

    /**
     * Return the difference between this time stamp, and the time stamp of
     * the other DateTimeStamp.
     * @param other The other {@code DateTimeStamp}
     * @return The difference between this time stamp, and the time stamp
     * of the other DateTimeStamp.
     */
    public double minus(DateTimeStamp other) {
        if (hasTimeStamp() && other.hasTimeStamp())
            return getTimeStamp() - other.getTimeStamp();
        if (hasDateStamp() && other.hasDateStamp()) {
            double thisInSeconds = (double)getDateTime().toEpochSecond() + ((double)(getDateTime().getNano() / 1_000_000)) / 1000.0d;
            double otherInSeconds = (double)other.getDateTime().toEpochSecond() + ((double)(other.getDateTime().getNano() / 1_000_000)) / 1000.0d;
            return thisInSeconds - otherInSeconds;