Skip to content

Commit

Permalink
cleanup rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jaggededgedjustice committed Apr 7, 2023
1 parent 83fe746 commit 0f6896e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 42 deletions.
18 changes: 9 additions & 9 deletions src/format/strftime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,13 +801,13 @@ fn test_strftime_docs_localized() {
let nd = NaiveDate::from_ymd_opt(2001, 7, 8).unwrap();

// date specifiers
assert_eq!(nd.format_localized("%b", Locale::de_DE).to_string(), "Jul");
assert_eq!(nd.format_localized("%B", Locale::de_DE).to_string(), "Juli");
assert_eq!(nd.format_localized("%h", Locale::de_DE).to_string(), "Jul");
assert_eq!(nd.format_localized("%a", Locale::de_DE).to_string(), "So");
assert_eq!(nd.format_localized("%A", Locale::de_DE).to_string(), "Sonntag");
assert_eq!(nd.format_localized("%D", Locale::de_DE).to_string(), "07/08/01");
assert_eq!(nd.format_localized("%x", Locale::de_DE).to_string(), "08.07.2001");
assert_eq!(nd.format_localized("%F", Locale::de_DE).to_string(), "2001-07-08");
assert_eq!(nd.format_localized("%v", Locale::de_DE).to_string(), " 8-Jul-2001");
assert_eq!(nd.format_localized("%b", Locale::de_DE).unwrap().to_string(), "Jul");
assert_eq!(nd.format_localized("%B", Locale::de_DE).unwrap().to_string(), "Juli");
assert_eq!(nd.format_localized("%h", Locale::de_DE).unwrap().to_string(), "Jul");
assert_eq!(nd.format_localized("%a", Locale::de_DE).unwrap().to_string(), "So");
assert_eq!(nd.format_localized("%A", Locale::de_DE).unwrap().to_string(), "Sonntag");
assert_eq!(nd.format_localized("%D", Locale::de_DE).unwrap().to_string(), "07/08/01");
assert_eq!(nd.format_localized("%x", Locale::de_DE).unwrap().to_string(), "08.07.2001");
assert_eq!(nd.format_localized("%F", Locale::de_DE).unwrap().to_string(), "2001-07-08");
assert_eq!(nd.format_localized("%v", Locale::de_DE).unwrap().to_string(), " 8-Jul-2001");
}
35 changes: 2 additions & 33 deletions src/naive/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,39 +1188,8 @@ impl NaiveDate {
&self,
fmt: &'a str,
locale: Locale,
) -> DelayedFormat<StrftimeItems<'a>> {
self.format_localized_with_items(StrftimeItems::new_with_locale(fmt, locale), locale)
}

/// Formats the date with the specified formatting items and locale.
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
#[inline]
pub fn format_localized_with_items<'a, I, B>(
&self,
items: I,
locale: Locale,
) -> DelayedFormat<I>
where
I: Iterator<Item = B> + Clone,
B: Borrow<Item<'a>>,
{
DelayedFormat::new_with_locale(Some(*self), None, items, locale)
}

/// Formats the date with the specified format string and locale.
///
/// See the [`crate::format::strftime`] module on the supported escape
/// sequences.
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
#[inline]
pub fn format_localized<'a>(
&self,
fmt: &'a str,
locale: Locale,
) -> DelayedFormat<StrftimeItems<'a>> {
self.format_localized_with_items(StrftimeItems::new_with_locale(fmt, locale), locale)
) -> Result<DelayedFormat<StrftimeItems<'a>>, ParseError> {
Ok(self.format_localized_with_items(StrftimeItems::new_with_locale(fmt, locale)?, locale))
}

/// Returns an iterator that steps by days across all representable dates.
Expand Down

0 comments on commit 0f6896e

Please sign in to comment.