Questions tagged [rust-chrono]

Date and time handling for Rust. (also known as rust-chrono) It aims to be a feature-complete superset of the time library.

Chrono is a date and time handling for Rust. In particular,

  • Chrono strictly adheres to ISO 8601.
  • Chrono is timezone-aware by default, with separate timezone-naive types.
  • Chrono is space-optimal and (while not being the primary goal) reasonably efficient.

Links:

83 questions
-1
votes
2 answers

How to subtract two Chrono DateTime objects to obtain the Duration difference between them, when the DateTime types differ?

I have two DateTime objects of different type which I would like to be able to subtract, or otherwise find the Duration difference between. Here is some example code: // First step: Want to be able to construct DateTimes for a set of different //…
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
-1
votes
1 answer

How to get the last Friday of every Month for next 12 months using chrono?

How can I get the last Friday of each month for the next N months in Rust? I am able to get every Friday for the next N weeks but not able to find out how to determine if it is the last Friday of a month. Currently I have: use chrono::{Date,…
Dallin
  • 141
  • 1
  • 7
-1
votes
1 answer

Trait diesel::Expression not implemented for NaiveDate, but it is for NaiveDateTime

I am trying to use chrono::NaiveDate as a database model field. Here is the model: use chrono::{NaiveDate, NaiveDateTime}; use diesel::{Insertable, Queryable}; use serde::{Deserialize, Serialize}; use crate::schema::users; #[derive(Debug,…
tedtanner
  • 577
  • 6
  • 19
-1
votes
1 answer

Issue with DateTime in Rust with juniper and chrono

I've got the problem, that I have a graphQL query, with a DateTime and cannot use it with juniper. At the documentation they write that they have the scalar type feature chrono::DateTime build in by default. So I pub imported the DateTime from…
Auryn
  • 1,117
  • 1
  • 13
  • 37
-2
votes
2 answers

How to convert a TimeZone enumeration variant into a fixed offset?

I am trying to convert a chrono_tz::Tz timezone offset into a fixed offset in units of number of hours. This is how I have managed to construct a Tz object: let input_string_timezone = "Europe/London"; let tz_timezone =…
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
-4
votes
2 answers

How can I use the Chrono library to get seconds?

I can get the date, the hours, minutes, seconds and nanoseconds in the date format, but I can't get seconds as a floating point or integer number. extern crate chrono; use chrono::prelude::*; fn main() { let local: DateTime =…
CFV
  • 740
  • 7
  • 26
-5
votes
1 answer

chrono convert DateTime to NaiveDate

After a while of fiddling, I decided to ask the question here, because - others shallst not waste as much fiddling time as I have. So, how to convert a DateTime into a NaiveDate with Rusts chrono crate? Here the "fill in the blanks" kind of…
BitTickler
  • 10,905
  • 5
  • 32
  • 53
-6
votes
1 answer

Why Do I Need To "Use" Things Sometimes That I'm Not Really Using In Rust?

Consider this code: use chrono::{Local, NaiveDate}; fn main() { let d = Local::now().naive_local().date(); println!("{}", d.num_days_from_ce()); } This fails to compile with the strange error, "no method named num_days_from_ce found for…
Jim
  • 3,821
  • 1
  • 28
  • 60
1 2 3 4 5
6