

package com.softsynth.shared.time;

/**
 * @author Phil Burk, (C) 2009 Mobileer Inc
 */
public class TimeStamp implements Comparable<TimeStamp> {
    private final double time;

    public TimeStamp(double time) {
        this.time = time;
    }

    public double getTime() {
        return time;
    }

    /**
     * @return -1 if (this &lt; t2), 0 if equal, or +1
     */
    @Override
    public int compareTo(TimeStamp t2) {
        if (time < t2.time)
            return -1;
        else if (time == t2.time)
            return 0;
        else
            return 1;
    }

    /**
     * Create a new TimeStamp at a relative offset in seconds.
     *
     * @param delta
     * @return earlier or later TimeStamp
     */
    public TimeStamp makeRelative(double delta) {
        return new TimeStamp(time + delta);
    }

}
