toDateTime method

DateTime toDateTime({
  1. bool toLocal = false,
})
inherited

Converts an instance to DateTime.

The result is in UTC time zone and has microsecond precision, as DateTime does not support nanosecond precision.

Use toLocal to convert to local time zone, instead of the default UTC.

Implementation

DateTime toDateTime({bool toLocal = false}) =>
    DateTime.fromMicrosecondsSinceEpoch(
        seconds.toInt() * Duration.microsecondsPerSecond + nanos ~/ 1000,
        isUtc: !toLocal);