Timestamp class

A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.

Timestamps are encoded using the Proleptic Gregorian Calendar, which extends the Gregorian calendar backwards to year one. Timestamps assume all minutes are 60 seconds long, i.e. leap seconds are 'smeared' so that no leap second table is needed for interpretation. Possible timestamp values range from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.

Implemented types

Constructors

Timestamp(int seconds, int nanoseconds)
seconds is the number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive. [...]
Timestamp.fromDateTime(DateTime dateTime)
Creates a new Timestamp instance from the given date. [...]
factory
Timestamp.fromMicrosecondsSinceEpoch(int microsecondsSinceEpoch)
Constructs a new Timestamp instance with the given microsecondsSinceEpoch.
factory
Timestamp.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch)
Constructs a new Timestamp instance with the given millisecondsSinceEpoch.
factory
Timestamp.now()
Constructs a Timestamp instance with current date and time. [...]
factory

Properties

hashCode int
The hash code for this object. [...]
read-only, override
microsecondsSinceEpoch int
The number of microseconds since the 'Unix epoch' 1970-01-01T00:00:00Z (UTC).
read-only
millisecondsSinceEpoch int
The number of milliseconds since the 'Unix epoch' 1970-01-01T00:00:00Z (UTC).
read-only
nanoseconds int
nanoseconds is the non-negative fractions of a second at nanosecond resolution.
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
seconds int
seconds is the number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
final

Methods

compareTo(Timestamp other) int
Compares this object to another object. [...]
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDateTime({bool isUtc}) DateTime
Convert a Timestamp to a DateTime object. This conversion causes a loss of precision and support millisecond precision.
toIso8601String() String
Returns an ISO-8601 full-precision extended format representation. The format is yyyy-MM-ddTHH:mm:ss.mmmuuunnnZ nanoseconds and microseconds are omitted if null
toString() String
A string representation of this object. [...]
override

Operators

operator ==(Object other) bool
The equality operator. [...]
override

Static Methods

parse(String text) Timestamp
The function parses a subset of ISO 8601 which includes the subset accepted by RFC 3339. [...]
tryAnyAsTimestamp(dynamic any) Timestamp
Try to get a Timestamp from either a DateTime, a Timestamp, a text or an int (ms since epoch)
tryParse(String text) Timestamp
parse or returns null