export class TimeInstant { static fromNanos ( nanos ) { return new TimeInstant ( nanos ) ; } static fromMillis ( ms ) { return new TimeInstant ( ms * 1e6 ) ; } static fromSeconds ( seconds ) { return new TimeInstant ( seconds * 1e9 ) ; } static fromSamples ( samples , hz ) { return new TimeInstant ( ( samples / hz ) * 1e9 ) ; } static from ( instant ) { return new TimeInstant ( instant . asNanos ( ) ) ; } static max ( time1 , time2 ) { if ( time1 . asNanos ( ) > time2 . asNanos ( ) ) return time1 ; else return time2 ; } static min ( time1 , time2 ) { if ( time1 . asNanos ( ) < time2 . asNanos ( ) ) return time1 ; else return time2 ; } static readonly ZERO = new TimeInstant ( 0 ) ; constructor ( protected nanos = 0 ) { } asSeconds ( ) { return this . nanos / 1e9 ; } asMillis ( ) { return this . nanos / 1e6 ; } asNanos ( ) { return Math . round ( this . nanos ) ; } asSamples ( hz ) { return this . nanos === 0 ? 0 : Math . round ( ( this . nanos / 1e9 ) * hz ) ; } sub ( time ) { return TimeInstant . fromNanos ( this . nanos - time . nanos ) ; } add ( time ) { return TimeInstant . fromNanos ( this . nanos + time . nanos ) ; } scale ( factor ) { return TimeInstant . fromNanos ( this . nanos * factor ) ; } mod ( factor ) { return TimeInstant . fromNanos ( this . nanos % factor ) ; } mul ( time ) { return this . nanos * time . nanos ; } div ( time ) { return this . nanos / time . nanos ; } gt ( time ) { return this . nanos > time . nanos ; } gte ( time ) { return this . nanos >= time . nanos ; } lt ( time ) { return this . nanos < time . nanos ; } lte ( time ) { return this . nanos <= time . nanos ; } eq ( time ) { return this . nanos === time . nanos ; } neq ( time ) { return this . nanos !== time . nanos ; } }