libperun

Class std.time.TimeInterval

Synopsis

public final class TimeInterval

Represents an interval in time, with nanosecond precision.

Fields

Constructors

public TimeInterval(long sec,long nano);

Construct the time interval with the specified seconds and nanoseconds.

public TimeInterval(long sec);

Construct the time interval in seconds.

Methods

public long toNanoSeconds();

Get the number of nanoseconds represented by this object. Note that this might overflow, because internally, two longs are used to represent the seconds+nanoseconds value, instead of just a single long.

public long toSeconds();

Get the number of seconds represented by this object (rounded down to the nearest integer).

public long toMinutes();

Get the number of minutes represented by this object.

public long toHours();

Get the number of hours represented by this object.

public long toDays();

Get the number of days represented by this object.

public long toWeeks();

Get the number of weeks represented by this object.

public TimeInterval opAdd(TimeInterval b);

Find the sum of two intervals.

public TimeInterval opSub(TimeInterval b);

Find the difference between two intervals.

public int opCompare(TimeInterval other);

Compare two TimeInterval objects. Returns -1 if the second object is larger, 0 if equal, 1 otherwise.

public bool opEquals(Object b);

Returns true if equal.

public TimeInterval seconds(long secs);

Return a TimeInterval instance corresponding to the value of this one, plus the specified number of seconds.

public TimeInterval minutes(long m);

Return a TimeInterval instance corresponding to the value of this one, plus the specified number of minutes.

public TimeInterval hours(long h);

Return a TimeInterval instance corresponding to the value of this one, plus the specified number of hours.

public TimeInterval days(long d);

Return a TimeInterval instance corresponding to the value of this one, plus the specified number of days.