toDuration method
A time column as the offset from the start of the day.
Duration is the right type: a time has no date, and a DateTime would
invent a day the database never stored.
Implementation
Duration toDuration() {
if (nanosecond % 1000 != 0) {
throw ArgumentError.value(
nanosecond,
'nanosecond',
'Duration resolves to microseconds and this value carries $nanosecond '
'nanoseconds. Keep the MssqlDateTimeValue, or read the column at '
'a scale of 6 or less.',
);
}
return Duration(
hours: hour,
minutes: minute,
seconds: second,
microseconds: nanosecond ~/ 1000,
);
}