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

The doc of spinoso_time::tzrs::Time::day_of_year() is inconsistent with its implementation #2072

Closed
lopopolo opened this issue Aug 11, 2022 · 1 comment · Fixed by #2073
Closed
Labels
A-ruby-core Area: Ruby Core types. C-bug Category: This is a bug.

Comments

@lopopolo
Copy link
Member

The doc of spinoso_time::tzrs::Time::day_of_year() is inconsistent with its implementation:

/// Returns an integer representing the day of the year, 1..366.
///
/// Can be used to implement [`Time#yday`].
///
/// # Examples
///
/// ```
/// # use spinoso_time::tzrs::{Time, TimeError};
/// # fn example() -> Result<(), TimeError> {
/// let now = Time::utc(2022, 7, 8, 12, 34, 56, 0)?;
/// assert_eq!(now.day_of_year(), 188);
/// # Ok(())
/// # }
/// # example().unwrap()
/// ```
///
/// [`Time#yday`]: https://ruby-doc.org/core-3.1.2/Time.html#method-i-yday
#[inline]
#[must_use]
pub fn day_of_year(&self) -> u16 {
self.inner.year_day()
}
}
.

tz::datetime::DateTime returns a year day in [0, 365], but the spinoso_time doc say it should be in 1..366 (1..=366 is more correct I think).

Originally posted by @x-hgg-x in artichoke/strftime-ruby#12 (comment)

@b-n
Copy link
Member

b-n commented Aug 12, 2022

Ah yes, this is also I noticed yesterday after paying with #1956. Nice to see it's fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ruby-core Area: Ruby Core types. C-bug Category: This is a bug.
Development

Successfully merging a pull request may close this issue.

2 participants