Skip to content

Commit

Permalink
Fix ISOWeekDate::weekday doc and examples
Browse files Browse the repository at this point in the history
As ISO-Week is Monday == day 1 based system,
it would be nice to give correct example to readers in this
context. So instead of `Weekday::to_sunday_zero_offset`
use `Weekday::to_monday_one_offset` in doc and examples.

Add an assert test into the example code to highlight above.

Signed-off-by: 35V LG84 <[email protected]>
  • Loading branch information
35VLG84 committed Jan 10, 2025
1 parent 737076a commit f8e2c85
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/civil/iso_week_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl ISOWeekDate {
/// Returns the day component of this ISO 8601 week date.
///
/// One can use methods on `Weekday` such as
/// [`Weekday::to_sunday_zero_offset`] to convert the weekday to a number.
/// [`Weekday::to_monday_one_offset`] to convert the weekday to a number.
///
/// # Example
///
Expand All @@ -253,6 +253,7 @@ impl ISOWeekDate {
/// assert_eq!(weekdate.year(), 1948);
/// assert_eq!(weekdate.week(), 53);
/// assert_eq!(weekdate.weekday(), Weekday::Friday);
/// assert_eq!(weekdate.weekday().to_monday_one_offset(), 5);
/// ```
#[inline]
pub fn weekday(self) -> Weekday {
Expand Down

0 comments on commit f8e2c85

Please sign in to comment.