leftTruncate method

DateTime leftTruncate(
  1. TimePrecision precision
)

Returns a new DateTime with it's fields set to their default values starting from the largest time unit up to the smallest time unit.

Implementation

DateTime leftTruncate(TimePrecision precision) {
  return Function.apply(truncate, [], {
    for (Symbol level in TimePrecision.values
        .map((Enum value) => value.toShortString())
        .toList()
        .sublist(precision.index)
        .map((String level) => Symbol(level)))
      level: true
  });
}