-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support the use of chrono::DateTime<Utc> using the type alias DateTim… #222
Conversation
…eUtc Add a test to ensure the DateTimeUtc is parsed and converted to SQL equivalent of TIMESTAMP
@billy1624 @tyt2y3 Any thoughts on this are welcome |
Btw... we have to update |
Move FixedOffset to its own `From` implementation Implement test for Utc
@billy1624 I have moved the |
src/value.rs
Outdated
#[cfg(feature = "with-chrono")] | ||
pub fn as_ref_date_time_utc(&self) -> Option<String> { | ||
match self { | ||
Self::DateTimeUtc(v) => v.as_ref().map(|v| v.naive_utc().to_string()), | ||
_ => panic!("not Value::DateTimeUtc"), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here should return Option<&DateTime<Utc>>
instead of serializing it as string
Support DateTime natively.
After researching and diving into the code, I found that the best way is to convert the
DateTime<Utc>
into aDateTime<FixedOffset>
with theFixedOffset
being based onchrono::Utc
. This is helpful especially in databases like MySQL which store theTIMESTAMP
in UTC despite a timezone being specified.