mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-03-26 15:48:13 -04:00
add extra timestamp functions
This commit is contained in:
parent
94ce43f944
commit
77f0f852a5
@ -77,6 +77,11 @@ class Timestamp extends Equatable implements Comparable<Timestamp> {
|
|||||||
@override
|
@override
|
||||||
int compareTo(Timestamp other) => value.compareTo(other.value);
|
int compareTo(Timestamp other) => value.compareTo(other.value);
|
||||||
|
|
||||||
|
bool operator <(Timestamp other) => compareTo(other) < 0;
|
||||||
|
bool operator <=(Timestamp other) => compareTo(other) <= 0;
|
||||||
|
bool operator >(Timestamp other) => compareTo(other) > 0;
|
||||||
|
bool operator >=(Timestamp other) => compareTo(other) >= 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => value.toString();
|
String toString() => value.toString();
|
||||||
String toJson() => toString();
|
String toJson() => toString();
|
||||||
@ -97,6 +102,11 @@ class TimestampDuration extends Equatable
|
|||||||
factory TimestampDuration.fromInt64(Int64 i64) => TimestampDuration(
|
factory TimestampDuration.fromInt64(Int64 i64) => TimestampDuration(
|
||||||
value: (BigInt.from((i64 >> 32).toUnsigned(32).toInt()) << 32) |
|
value: (BigInt.from((i64 >> 32).toUnsigned(32).toInt()) << 32) |
|
||||||
BigInt.from(i64.toUnsigned(32).toInt()));
|
BigInt.from(i64.toUnsigned(32).toInt()));
|
||||||
|
factory TimestampDuration.fromMillis(int millis) =>
|
||||||
|
TimestampDuration(value: BigInt.from(millis) * BigInt.from(1000));
|
||||||
|
factory TimestampDuration.fromDuration(Duration d) => TimestampDuration(
|
||||||
|
value: BigInt.from(d.inSeconds) * BigInt.from(1000000) +
|
||||||
|
BigInt.from(d.inMicroseconds % 1000000));
|
||||||
factory TimestampDuration.fromString(String s) =>
|
factory TimestampDuration.fromString(String s) =>
|
||||||
TimestampDuration(value: BigInt.parse(s));
|
TimestampDuration(value: BigInt.parse(s));
|
||||||
factory TimestampDuration.fromJson(dynamic json) =>
|
factory TimestampDuration.fromJson(dynamic json) =>
|
||||||
@ -108,6 +118,11 @@ class TimestampDuration extends Equatable
|
|||||||
@override
|
@override
|
||||||
int compareTo(TimestampDuration other) => value.compareTo(other.value);
|
int compareTo(TimestampDuration other) => value.compareTo(other.value);
|
||||||
|
|
||||||
|
bool operator <(TimestampDuration other) => compareTo(other) < 0;
|
||||||
|
bool operator <=(TimestampDuration other) => compareTo(other) <= 0;
|
||||||
|
bool operator >(TimestampDuration other) => compareTo(other) > 0;
|
||||||
|
bool operator >=(TimestampDuration other) => compareTo(other) >= 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => value.toString();
|
String toString() => value.toString();
|
||||||
String toJson() => toString();
|
String toJson() => toString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user