Time.duration constructor

Time.duration({
  1. int ticks = 0,
  2. num? days,
  3. num? seconds,
  4. num? minutes,
})

For a handy interface which does the conversions automatically, use Time.duration:

Time.duration
ticks integer number of ticks(optional)
days number of ingame days(optional)
minutes number of minutes(optional)
seconds number of seconds(optional)

So we can write 1min 30s the following ways(also using fractional timesteps):

t = Time.seconds(90),
t = Time.duration(minutes: 1.5),
t = Time.duration(minutes: 1, seconds: 30),

Implementation

factory Time.duration({
  int ticks = 0,
  num? days,
  num? seconds,
  num? minutes,
}) =>
    Time(ticks +
        ((days ?? 0) * _TICKSINDAY +
                (seconds ?? 0 + (minutes ?? 0) * 60) * _TICKSINSECOND)
            .toInt());