View source

abstract thx.Timestamp(Float) from Float to Float

Available on all platforms

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

Class Fields

inline function 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.

inline function fromDate(d:Date):Timestamp

inline function fromString(s:String):Timestamp

inline function now():Timestamp

Instance Fields

function 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).

function 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).

function 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

inline function toDate():Date

inline function toString():String