Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
tisonkun opened this issue Sep 11, 2024 · 1 comment · Fixed by #185
Closed

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

tisonkun opened this issue Sep 11, 2024 · 1 comment · Fixed by #185
Labels
documentation Improvements or additions to documentation

Comments

@tisonkun
Copy link

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
Copy link
Owner

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

@BurntSushi BurntSushi added the documentation Improvements or additions to documentation label Sep 11, 2024
BurntSushi added a commit that referenced this issue Jan 1, 2025
Specifically, this puts harder and more explicit guarantees on the range
of values returned by methods like `year`, `month`, `day`, `hour` and so
on.

Fixes #130
BurntSushi added a commit that referenced this issue Jan 1, 2025
Specifically, this puts harder and more explicit guarantees on the range
of values returned by methods like `year`, `month`, `day`, `hour` and so
on.

Fixes #130
BurntSushi added a commit that referenced this issue Jan 1, 2025
Specifically, this puts harder and more explicit guarantees on the range
of values returned by methods like `year`, `month`, `day`, `hour` and so
on.

Fixes #130
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants