rfc_3339_date_time_serializer 1.0.1

Dart native js
Flutter Android iOS web

RFC 3339 DateTime serializer for built_value. To address the issue with datetimes with more than 6 characters in time-secfrac.

rfc_3339_date_time_serializer #

An RFC3339DateTimeSerializer serializer class for built_value, created to address the issue about Dart's DateTime.parse not working with RFC 3339.

Why is this package needed? #

ISO 8601 has a character limit for time-secfrac part equal to 6. RFC 3339 does not have that limit. Thanks to this, datetimes introducing more than 6 characters in time-secfrac are invalid for DateTime.parse, because it works only with ISO 8601.

For example, Go's encoding/json serializes dates with 7 time-secfrac characters.

Usage #

In your serializers.dart:

import 'rfc_3339_date_time_serializer/rfc_3339_date_time_serializer.dart';

@SerializersFor(const [/* (...) */])
final Serializers modelsSerializers = (_$modelsSerializers.toBuilder()
      ..addPlugin(StandardJsonPlugin())
      ..add(RFC3339DateTimeSerializer())) // this is the line you need to add
    .build();
1
likes
100
pub points
42%
popularity

Publisher

wolszon.me

RFC 3339 DateTime serializer for built_value. To address the issue with datetimes with more than 6 characters in time-secfrac.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

built_value

More

Packages that depend on rfc_3339_date_time_serializer