BurntSushi / jiff

A date-time library for Rust that encourages you to jump into the pit of success.
The Unlicense
1.77k stars 35 forks source link

Is it possible a month is negative or out of 1..=12? #130

Open tisonkun opened 2 months ago

tisonkun commented 2 months ago

Hi @BurntSushi.

I noticed that month method is defined as:

    #[inline]
    pub fn month(&self) -> i8 {
        self.date().month()
    }

I wonder if it's possible month is negative or out of 1..=12?

BurntSushi commented 2 months ago

No, it isn't possible. We should add that guarantee to the docs. And for other similar methods like day.

But it is mentioned in the constructor for civil::Date: https://docs.rs/jiff/latest/jiff/civil/struct.Date.html#method.new