git-touch-android-ios-app/packages/gql_github/lib/utils/date_time_serializer.dart

29 lines
700 B
Dart
Raw Normal View History

2021-01-17 15:08:32 +01:00
import 'package:built_value/serializer.dart';
class DateTimeSerializer implements PrimitiveSerializer<DateTime> {
@override
DateTime deserialize(
Serializers serializers,
Object serialized, {
FullType specifiedType = FullType.unspecified,
}) {
assert(serialized is String,
"DateTimeSerializer expected 'String' but got ${serialized.runtimeType}");
2021-05-16 09:16:35 +02:00
return DateTime.parse(serialized as String);
2021-01-17 15:08:32 +01:00
}
@override
Object serialize(
Serializers serializers,
DateTime dt, {
FullType specifiedType = FullType.unspecified,
}) =>
dt.toString();
@override
Iterable<Type> get types => [DateTime];
@override
String get wireName => 'DateTime';
2021-01-17 15:08:32 +01:00
}