Returns a string representation of this Duration
.
Returns a string with hours, minutes, seconds, and microseconds, in the following format: HH:MM:SS.mmmmmm
. For example,
var d = new Duration(days:1, hours:1, minutes:33, microseconds: 500); d.toString(); // "25:33:00.000500"
String toString() { String sixDigits(int n) { if (n >= 100000) return "$n"; if (n >= 10000) return "0$n"; if (n >= 1000) return "00$n"; if (n >= 100) return "000$n"; if (n >= 10) return "0000$n"; return "00000$n"; } String twoDigits(int n) { if (n >= 10) return "$n"; return "0$n"; } if (inMicroseconds < 0) { return "-${-this}"; } String twoDigitMinutes = twoDigits(inMinutes.remainder(minutesPerHour)); String twoDigitSeconds = twoDigits(inSeconds.remainder(secondsPerMinute)); String sixDigitUs = sixDigits(inMicroseconds.remainder(microsecondsPerSecond)); return "$inHours:$twoDigitMinutes:$twoDigitSeconds.$sixDigitUs"; }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-core/Duration/toString.html