decodeDateTimeFactory static method
Expects the map
to be either a common.DateTimeFactory
or a String
containing one of the following values:
local
utc
Implementation
static common.DateTimeFactory? decodeDateTimeFactory(
dynamic map, {
bool validate = false,
}) {
common.DateTimeFactory? result;
if (map is common.DateTimeFactory) {
result = map;
} else if (map != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/date_time_factory',
value: map,
validate: validate,
));
switch (map) {
case 'local':
result = const common.LocalDateTimeFactory();
break;
case 'utc':
result = const common.UTCDateTimeFactory();
break;
default:
throw Exception('Unknown [DateTimeFactory] encountered: [$map]');
}
}
return result;
}