decodeDateTimeExtents static method

DateTimeExtents? decodeDateTimeExtents(
  1. dynamic map, {
  2. bool validate = false,
})

Decodes the object from a Map-like dynamic structure. This expects the JSON format to be of the following structure:

{
  "end": <DateTime>,
  "start": <DateTime>
}

Implementation

static common.DateTimeExtents? decodeDateTimeExtents(
  dynamic map, {
  bool validate = false,
}) {
  common.DateTimeExtents? result;

  if (map is common.DateTimeExtents) {
    result = map;
  } else if (map != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/date_time_extents',
      value: map,
      validate: validate,
    ));

    result = common.DateTimeExtents(
      end: JsonClass.parseDateTime(map['end'])!,
      start: JsonClass.parseDateTime(map['start'])!,
    );
  }

  return result;
}