question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[dart-dio][dart-dio-next] Support Date Type

See original GitHub issue

Is your feature request related to a problem? Please describe.

The OpenAPI definition differentiates between Date and DateTime. The dart-dio-next generator supports only DateTime without the additional timemachine library, which causes deserialization errors for Date on the server side.

Describe the solution you’d like

The goal is to distinguish between Date and DateTime in serialization. Due to BuiltValue only one serializer can be specified for one class. While adding the serializer, FullType supports optional parameters, which maybe provides a possibility to distinguish between Date and DateTime using {{isDate}}. The Iso8601DateTimeSerializer could be extendend by checking these parameters and use DateFormat('yyyy-MM-dd') to serialize Date.

Describe alternatives you’ve considered

Alternative approaches are to use the dart generator, which already distinguishes between DateTime and Date, or to use the timemachine library. The first approach unfortunately lacks the wide possibilities of Dio like interceptors and the timemachine library adds more dependencies and often requires a conversion between timemachine classes and DateTime.

Additional context

As mentioned in #8869, support for Date would be a useful extension to the next generation dart dio generator @agilob @kuhnroyal. I would like to thank you for the current version of the new generator, it looks very promising.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kuhnroyalcommented, Mar 30, 2021

We could create a custom Date class with helpers for to/fromDateTime() and use that instead.

0reactions
francescoberardicommented, Aug 16, 2022

Is it possibile to add the support to Date type also for json_serializable serializer?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using the Date/Time Extended data type - Microsoft Support
The Date/Time Extended data type stores date and time information and is similar to the Date/Time data type, but it provides a larger...
Read more >
DATE Data Type - Apache Impala
Use the DATE data type to store date values. The DATE type is supported for Avro, HBase, Kudu, Parquet, and Text. Range: 0001-01-01...
Read more >
Supported date formats - Amazon QuickSight
Amazon QuickSight supports the date and time formats described in this section. Before you add data to Amazon QuickSight, check if your date...
Read more >
Dates and times - Looker Studio Help - Google Support
Date and time data types; Date & Time (compatibility mode); Upgrade a compatibility mode date field; Use dates and times in charts; Change...
Read more >
Date functions | BigQuery - Google Cloud
Google Standard SQL for BigQuery supports the following date functions. ... Returns the current date as of the specified or default time zone....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found