dateTimeToJson function

dynamic dateTimeToJson(
  1. dynamic value
)

Date time toJson serializer.

Implementation

dynamic dateTimeToJson(dynamic value) {
  print(value is DateTime);
  if (value is DateTime) {
    return value.isUtc
        ? value.toIso8601String()
        : value.toUtc().toIso8601String();
  } else if (value is Iterable) {
    return value.map(dateTimeToJson);
  } else if (value is Map) {
    return value.map((k, v) => MapEntry(k, dateTimeToJson(v)));
  }

  return value;
}