duration library Null safety

Support for doing something awesome.

More dartdocs go here.

Classes

DurationTersity
Provides constants used to control terity of prettyDuration and printDuration.

Extensions

DurExt

Constants

aDay → const Duration
Duration of a day
Duration(days: 1)
aMicrosecond → const Duration
Duration of a microsecond
Duration(microseconds: 1)
aMillisecond → const Duration
Duration of a millisecond
Duration(milliseconds: 1)
aMinute → const Duration
Duration of a minute
Duration(minutes: 1)
anHour → const Duration
Duration of an hour
Duration(hours: 1)
aSecond → const Duration
Duration of a second
Duration(seconds: 1)
aWeek → const Duration
Duration of a week
Duration(days: 7)

Functions

days(int days) Duration
hours(int hours) Duration
minutes(int minutes) Duration
ms(int milliseconds) Duration
parseDuration(String input, {String separator = ','}) Duration
Parses duration string formatted by prettyDuration into Duration. separator defines the string that splits duration components in the string.
parseTime(String input) Duration
Parses duration string formatted by Duration.toString() to Duration. The string should be of form hours:minutes:seconds.microseconds
prettyDuration(Duration duration, {DurationTersity tersity = DurationTersity.second, DurationTersity upperTersity = DurationTersity.week, DurationLocale locale = const EnglishDurationLocale(), String? spacer, String? delimiter, String? conjunction, bool abbreviated = false, bool first = false}) String
Converts duration into legible string with given level of tersity
prettyMilliseconds(Duration duration, {bool terse = false, DurationLocale language = const EnglishDurationLocale(), String separator = ' ', bool abbreviated = false}) String
Pretty format duration in terms of milliseconds.
prettySeconds(Duration duration, {bool terse = false, DurationLocale language = const EnglishDurationLocale(), String separator = ' ', String delimiter = ' ', bool abbreviated = false}) String
Pretty format duration in terms of seconds.
printDuration(Duration duration, {DurationTersity tersity = DurationTersity.second, DurationTersity upperTersity = DurationTersity.week, DurationLocale locale = const EnglishDurationLocale(), String? spacer, String? delimiter, String? conjugation, bool abbreviated = false}) String
printMilliseconds(Duration duration, {bool terse = false, DurationLocale language = const EnglishDurationLocale(), String separator = ' ', bool abbreviated = false}) String
Pretty print duration in terms of milliseconds.
seconds(int seconds) Duration
tryParseDuration(String input) Duration?
tryParseDurationAny(String input) Duration?
tryParseTime(String input) Duration?
us(int microseconds) Duration