Skip to content

Commit

Permalink
doc: improve 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 an example that matches the ISO 8601 standard. So instead
of only mentioning `Weekday::to_sunday_zero_offset`, we mention
`Weekday::to_monday_one_offset` as well.

Closes #196
  • Loading branch information
35VLG84 authored and BurntSushi committed Jan 13, 2025
1 parent 8bccfd9 commit db7c6e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Deprecations:

Enhancements:

* [#196](https://github.com/BurntSushi/jiff/discussions/196):
Improve ISO week date documentation regarding weekday offsets.
* [#197](https://github.com/BurntSushi/jiff/discussions/197):
Add `Zoned::iso_week_date`, `DateTime::iso_week_date` and
`Date::iso_week_date`.
Expand Down
9 changes: 8 additions & 1 deletion src/civil/iso_week_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ 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`]
/// and
/// [`Weekday::to_sunday_zero_offset`]
/// to convert the weekday to a number.
///
/// # Example
///
Expand All @@ -254,6 +257,10 @@ impl ISOWeekDate {
/// assert_eq!(weekdate.year(), 1948);
/// assert_eq!(weekdate.week(), 53);
/// assert_eq!(weekdate.weekday(), Weekday::Friday);
/// assert_eq!(weekdate.weekday().to_monday_zero_offset(), 4);
/// assert_eq!(weekdate.weekday().to_monday_one_offset(), 5);
/// assert_eq!(weekdate.weekday().to_sunday_zero_offset(), 5);
/// assert_eq!(weekdate.weekday().to_sunday_one_offset(), 6);
/// ```
#[inline]
pub fn weekday(self) -> Weekday {
Expand Down

0 comments on commit db7c6e2

Please sign in to comment.