from static method

Hora from(
  1. Map<String, dynamic> map, {
  2. bool utc = false,
})

Creates a Hora from a map of date-time components.

Supported keys:

  • year / years
  • month / months (1-12)
  • day / days / date
  • hour / hours
  • minute / minutes
  • second / seconds
  • millisecond / milliseconds
  • microsecond / microseconds

Implementation

static Hora from(Map<String, dynamic> map, {bool utc = false}) {
  final year = _getInt(map, [DateTimeKeys.year, DateTimeKeys.years]) ??
      DateTime.now().year;
  final month = _getInt(map, [DateTimeKeys.month, DateTimeKeys.months]) ?? 1;
  final day = _getInt(
        map,
        [DateTimeKeys.day, DateTimeKeys.days, DateTimeKeys.date],
      ) ??
      1;
  final hour = _getInt(map, [DateTimeKeys.hour, DateTimeKeys.hours]) ?? 0;
  final minute =
      _getInt(map, [DateTimeKeys.minute, DateTimeKeys.minutes]) ?? 0;
  final second =
      _getInt(map, [DateTimeKeys.second, DateTimeKeys.seconds]) ?? 0;
  final millisecond =
      _getInt(map, [DateTimeKeys.millisecond, DateTimeKeys.milliseconds]) ??
          0;
  final microsecond =
      _getInt(map, [DateTimeKeys.microsecond, DateTimeKeys.microseconds]) ??
          0;

  return Hora.of(
    year: year,
    month: month,
    day: day,
    hour: hour,
    minute: minute,
    second: second,
    millisecond: millisecond,
    microsecond: microsecond,
    utc: utc,
  );
}