Timestamp
provides additional methods on top of the Float
as well as
automatic casting from and to Date/String.
import thx.Timestamp;
@author Jason O'Neil @author Franco Ponticelli
Methods
snapNext (period:TimePeriod):Timestamp
Snaps a time to the next second, minute, hour, day, week, month or year.
Parameters:
time | The unix time in milliseconds. See date.getTime() |
---|---|
period | Either: Second, Minute, Hour, Day, Week, Month or Year |
Returns:
The unix time of the snapped date (In milliseconds).
snapPrev (period:TimePeriod):Timestamp
Snaps a time to the previous second, minute, hour, day, week, month or year.
Parameters:
time | The unix time in milliseconds. See date.getTime() |
---|---|
period | Either: Second, Minute, Hour, Day, Week, Month or Year |
Returns:
The unix time of the snapped date (In milliseconds).
snapTo (period:TimePeriod):Timestamp
Snaps a time to the nearest second, minute, hour, day, week, month or year.
Parameters:
period | Either: Second, Minute, Hour, Day, Week, Month or Year |
---|
Static methods
staticinline create (year:Int, ?month:Int, ?day:Int, ?hour:Int, ?minute:Int, ?second:Int):Timestamp
Creates a timestamp by using the passed year, month, day, hour, minute, second.
Note that each argument can overflow its normal boundaries (e.g. a month value of -33
is perfectly valid)
and the method will normalize that value by offsetting the other arguments by the right amount.