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

Feature Request: Converting between `Interval` and `chrono::Duration` #922

Closed
KeenS opened this Issue May 26, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@KeenS
Contributor

KeenS commented May 26, 2017

I want to use interval type in PostgreSQL with diesel. The counter part sql type in diesel is diesel::types::Interval.
diesel::types::Interval can be converted only from and to PgInterval (CF http://docs.diesel.rs/diesel/types/struct.Interval.html) but it's not so convenient using around in the program because it cannot interact with chrono types and it seems to depends on Postgresql.
Thus to interact with chrono types and to be independent from postgresql (and diesel itself), I want to select interval type from the DB as Duration type.

@Eijebong

This comment has been minimized.

Member

Eijebong commented May 27, 2017

The question is how do you translate '1 month'::interval to a Duration ?

@KeenS

This comment has been minimized.

Contributor

KeenS commented May 29, 2017

Thank you for pointing the problem out. I found I confused duration with interval, it's intervals on the calendar, not time intervals. Then I close this as invalid request. I'm sorry for troubling you.

@KeenS KeenS closed this May 29, 2017

@vityafx

This comment has been minimized.

vityafx commented Feb 6, 2018

I have implemented storing of chrono::Duration in the BigInt field of SQLite 3. I decided to use BigInt since it converts to i64 type which is the minimal unit the chrono::Duration. I am gonna implement it for the pgsql too tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment