Skip to content
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

Add MIN_DATETIME and MAX_DATETIME #386

Closed
Kestrer opened this issue Jan 8, 2020 · 10 comments · Fixed by #452
Closed

Add MIN_DATETIME and MAX_DATETIME #386

Kestrer opened this issue Jan 8, 2020 · 10 comments · Fixed by #452

Comments

@Kestrer
Copy link

Kestrer commented Jan 8, 2020

Also add the naive versions. These would just be useful to have for completeness in the library.

@quodlibetor
Copy link
Contributor

Agreed! The naive versions should be pretty trivial to add based on the impls of MIN_DATE and MAX_DATE, I'm not sure if tz-aware versions (maybe other than UTC?) should be added.

@technetos
Copy link

Hi, is it possible to get alittle more clarification on this?

@Kestrer
Copy link
Author

Kestrer commented Feb 29, 2020

@technetos something like:

// in naive
pub const MIN_TIME: NaiveTime = { secs: 0, frac: 0 };
pub const MAX_TIME: NaiveTime = { secs: u32::MAX, frac: u32::MAX };
pub const MIN_DATETIME: NaiveDateTime = { date: MIN_DATE, time: MIN_TIME };
pub const MAX_DATETIME: NaiveDateTime = { date: MAX_DATE, time: MAX_TIME };

// in root
pub const MIN_DATETIME: DateTime<Utc> = { datetime: naive::MIN_DATETIME, offset: Utc };
pub const MAX_DATETIME: DateTime<Utc> = { datetime: naive::MAX_DATETIME, offset: Utc };

Perhaps MIN_UTC_DATETIME is a better name, or you could even use associated trait consts for TimeZone (although I don't know if that's possible).

robyoung added a commit to robyoung/chrono that referenced this issue Jul 10, 2020
robyoung added a commit to robyoung/chrono that referenced this issue Jul 10, 2020
robyoung added a commit to robyoung/chrono that referenced this issue Jul 10, 2020
@LAC-Tech
Copy link

Hi, while I can confirm these are now in the code, they're not in the docs (Came in here to ask about them!).

@djc
Copy link
Contributor

djc commented Apr 12, 2022

Where are you looking? I can find them in the docs. Note: these are not associated constants, they're just bare constants in for example the naive module.

@LAC-Tech
Copy link

https://docs.rs/chrono/0.4.0/chrono/index.html#constants

Pretty much here. I'm pretty new to rust, so very possible this is my issue, but I can't find them documented anywhere.

@djc
Copy link
Contributor

djc commented Apr 13, 2022

Note this link:

Screenshot 2022-04-13 at 09 18 54

You're looking at documentation for 0.4.0, which is almost 5 years old at this point.

@rikvdkleij
Copy link

rikvdkleij commented Jun 17, 2022

The issue is that MIN_TIME and MAX_TIME of NaiveTime are not exposed by re-exporting while the other ones are.

See

chrono/src/lib.rs

Lines 475 to 490 in 13e1d48

pub use date::{Date, MAX_DATE, MIN_DATE};
mod datetime;
#[cfg(feature = "rustc-serialize")]
pub use datetime::rustc_serialize::TsSeconds;
pub use datetime::{DateTime, SecondsFormat, MAX_DATETIME, MIN_DATETIME};
pub mod format;
/// L10n locales.
#[cfg(feature = "unstable-locales")]
pub use format::Locale;
pub use format::{ParseError, ParseResult};
pub mod naive;
#[doc(no_inline)]
pub use naive::{IsoWeek, NaiveDate, NaiveDateTime, NaiveTime, NaiveWeek};

@djc
Copy link
Contributor

djc commented Jun 17, 2022

Feel free to submit a PR fixing that.

@rikvdkleij
Copy link

@djc Done, see #713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants