Skip to content

Commit

Permalink
civil: remove Date::to_iso_week_date and ISOWeekDate::to_date
Browse files Browse the repository at this point in the history
These were deprecated. Users should use `Date::iso_week_date` and
`ISOWeekDate::date` instead.

Fixes #218
  • Loading branch information
BurntSushi committed Jan 30, 2025
1 parent 2e7720f commit cec2944
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Change the behavior of the deprecated `%V` conversion specifier in
`jiff::fmt::strtime` from formatting an IANA time zone identifier to formatting
an ISO 8601 week number. To format an IANA time zone identifier, use `%Q` or
`%:Q` (which were introduced in `jiff 0.1`).
* [#218](https://github.com/BurntSushi/jiff/issues/218):
In order to make naming a little more consistent between `Zoned`
and `civil::Date`, the `civil::Date::to_iso_week_date` and
`civil::ISOWeekDate::to_date` APIs were renamed to `civil::Date::iso_week_date`
and `civil::ISOWeekDate::date`.


0.1.29 (TBD)
Expand Down
15 changes: 1 addition & 14 deletions src/civil/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl Date {
/// precisely to the minimum and maximum values of a `Date`. Therefore,
/// converting between them is lossless and infallible.
///
/// This routine is equivalent to [`ISOWeekDate::to_date`]. It is also
/// This routine is equivalent to [`ISOWeekDate::date`]. It is also
/// available via a `From<ISOWeekDate>` trait implementation for `Date`.
///
/// [ISO 8601 week date]: https://en.wikipedia.org/wiki/ISO_week_date
Expand Down Expand Up @@ -2055,19 +2055,6 @@ impl Date {
}
}

/// Deprecated APIs.
impl Date {
/// A deprecated equivalent to [`Date::iso_week_date`].
///
/// This method will be removed in `jiff 0.2`. This was done to make naming
/// more consistent throughout the crate.
#[deprecated(since = "0.1.23", note = "use Date::iso_week_date instead")]
#[inline]
pub fn to_iso_week_date(self) -> ISOWeekDate {
self.iso_week_date()
}
}

// Constants used for converting between Gregorian calendar dates and Unix
// epoch days.
//
Expand Down
31 changes: 9 additions & 22 deletions src/civil/iso_week_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ use crate::{
///
/// let d = date(2019, 12, 30);
/// let weekdate = ISOWeekDate::new(2020, 1, Weekday::Monday).unwrap();
/// assert_eq!(d.to_iso_week_date(), weekdate);
/// assert_eq!(d.iso_week_date(), weekdate);
///
/// let d = date(2024, 3, 9);
/// let weekdate = ISOWeekDate::new(2024, 10, Weekday::Saturday).unwrap();
/// assert_eq!(d.to_iso_week_date(), weekdate);
/// assert_eq!(d.iso_week_date(), weekdate);
/// ```
///
/// # Example: overlapping leap and long years
Expand All @@ -69,7 +69,7 @@ use crate::{
/// let mut overlapping = vec![];
/// for year in 1900..=1999 {
/// let date = date(year, 1, 1);
/// if date.in_leap_year() && date.to_iso_week_date().in_long_year() {
/// if date.in_leap_year() && date.iso_week_date().in_long_year() {
/// overlapping.push(year);
/// }
/// }
Expand Down Expand Up @@ -206,8 +206,8 @@ impl ISOWeekDate {
/// set based on the minimum and maximum values of a `Date`. Therefore,
/// converting to and from `Date` values is non-lossy and infallible.
///
/// This routine is equivalent to [`Date::to_iso_week_date`]. This
/// routine is also available via a `From<Date>` trait implementation for
/// This routine is equivalent to [`Date::iso_week_date`]. This routine
/// is also available via a `From<Date>` trait implementation for
/// `ISOWeekDate`.
///
/// # Example
Expand Down Expand Up @@ -239,7 +239,7 @@ impl ISOWeekDate {
/// ```
/// use jiff::civil::date;
///
/// let weekdate = date(2019, 12, 30).to_iso_week_date();
/// let weekdate = date(2019, 12, 30).iso_week_date();
/// assert_eq!(weekdate.year(), 2020);
/// ```
#[inline]
Expand All @@ -259,11 +259,11 @@ impl ISOWeekDate {
/// ```
/// use jiff::civil::date;
///
/// let weekdate = date(2019, 12, 30).to_iso_week_date();
/// let weekdate = date(2019, 12, 30).iso_week_date();
/// assert_eq!(weekdate.year(), 2020);
/// assert_eq!(weekdate.week(), 1);
///
/// let weekdate = date(1948, 12, 31).to_iso_week_date();
/// let weekdate = date(1948, 12, 31).iso_week_date();
/// assert_eq!(weekdate.year(), 1948);
/// assert_eq!(weekdate.week(), 53);
/// ```
Expand All @@ -285,7 +285,7 @@ impl ISOWeekDate {
/// ```
/// use jiff::civil::{date, Weekday};
///
/// let weekdate = date(1948, 12, 31).to_iso_week_date();
/// let weekdate = date(1948, 12, 31).iso_week_date();
/// assert_eq!(weekdate.year(), 1948);
/// assert_eq!(weekdate.week(), 53);
/// assert_eq!(weekdate.weekday(), Weekday::Friday);
Expand Down Expand Up @@ -638,19 +638,6 @@ impl ISOWeekDate {
}
}

/// Deprecated APIs.
impl ISOWeekDate {
/// A deprecated equivalent to [`ISOWeekDate::date`].
///
/// This method will be removed in `jiff 0.2`. This was done to make naming
/// more consistent throughout the crate.
#[deprecated(since = "0.1.26", note = "use ISOWeekDate::date instead")]
#[inline]
pub fn to_date(self) -> Date {
Date::from_iso_week_date(self)
}
}

impl ISOWeekDate {
/// Creates a new ISO week date from ranged values.
///
Expand Down

0 comments on commit cec2944

Please sign in to comment.