google / json_serializable.dart

Generates utilities to aid in serializing to/from JSON.
https://pub.dev/packages/json_serializable
BSD 3-Clause "New" or "Revised" License
1.55k stars 397 forks source link

Proposal: Always convert DateTime to UTC during serialization #1371

Open Rexios80 opened 10 months ago

Rexios80 commented 10 months ago

Since dates should pretty much always be stored in UTC would it be reasonable to automatically convert DateTime objects to UTC during serialization? Could this at least be an option in the generator? I know I could write my own DateTime converter but then I have to remember to use it every time I create a new DateTime field.

I see https://github.com/google/json_serializable.dart/pull/811, but that was abandoned. I think making this a generator setting, maybe off by default to prevent issues with existing codebases, would be ideal.