Make write_rfc3339 available in no_std

This commit is contained in:
Paul Dicker 2023-07-25 07:54:43 +02:00 committed by Paul Dicker
parent 2cc1db1dae
commit 5f80aafe0d
2 changed files with 9 additions and 12 deletions

View File

@ -10,19 +10,17 @@ use core::borrow::Borrow;
use core::fmt; use core::fmt;
use core::fmt::Write; use core::fmt::Write;
use crate::datetime::SecondsFormat;
#[cfg(any(feature = "alloc", feature = "std"))] #[cfg(any(feature = "alloc", feature = "std"))]
use crate::naive::{NaiveDate, NaiveDateTime, NaiveTime}; use crate::offset::Offset;
use crate::{Datelike, FixedOffset, NaiveDateTime, Timelike};
#[cfg(any(feature = "alloc", feature = "std"))] #[cfg(any(feature = "alloc", feature = "std"))]
use crate::offset::{FixedOffset, Offset}; use crate::{NaiveDate, NaiveTime, Weekday};
#[cfg(any(feature = "alloc", feature = "std"))]
use crate::{Datelike, SecondsFormat, Timelike, Weekday};
use super::locales; use super::locales;
use super::{Colons, OffsetFormat, OffsetPrecision, Pad};
#[cfg(any(feature = "alloc", feature = "std"))] #[cfg(any(feature = "alloc", feature = "std"))]
use super::{ use super::{Fixed, InternalFixed, InternalInternal, Item, Locale, Numeric};
Colons, Fixed, InternalFixed, InternalInternal, Item, Locale, Numeric, OffsetFormat,
OffsetPrecision, Pad,
};
use locales::*; use locales::*;
/// A *temporary* object which can be used as an argument to `format!` or others. /// A *temporary* object which can be used as an argument to `format!` or others.
@ -447,7 +445,6 @@ fn format_inner(
} }
} }
#[cfg(any(feature = "alloc", feature = "std"))]
impl OffsetFormat { impl OffsetFormat {
/// Writes an offset from UTC with the format defined by `self`. /// Writes an offset from UTC with the format defined by `self`.
fn format(&self, w: &mut impl Write, off: FixedOffset) -> fmt::Result { fn format(&self, w: &mut impl Write, off: FixedOffset) -> fmt::Result {
@ -528,7 +525,6 @@ impl OffsetFormat {
} }
/// Writes the date, time and offset to the string. same as `%Y-%m-%dT%H:%M:%S%.f%:z` /// Writes the date, time and offset to the string. same as `%Y-%m-%dT%H:%M:%S%.f%:z`
#[cfg(any(feature = "alloc", feature = "std"))]
#[inline] #[inline]
pub(crate) fn write_rfc3339( pub(crate) fn write_rfc3339(
w: &mut impl Write, w: &mut impl Write,

View File

@ -52,11 +52,12 @@ pub(crate) mod locales;
pub(crate) use formatting::write_hundreds; pub(crate) use formatting::write_hundreds;
#[cfg(any(feature = "alloc", feature = "std"))] #[cfg(any(feature = "alloc", feature = "std"))]
pub(crate) use formatting::write_rfc2822;
pub(crate) use formatting::write_rfc3339;
#[cfg(any(feature = "alloc", feature = "std"))]
pub use formatting::{format, format_item, DelayedFormat}; pub use formatting::{format, format_item, DelayedFormat};
#[cfg(feature = "unstable-locales")] #[cfg(feature = "unstable-locales")]
pub use formatting::{format_item_localized, format_localized}; pub use formatting::{format_item_localized, format_localized};
#[cfg(any(feature = "alloc", feature = "std"))]
pub(crate) use formatting::{write_rfc2822, write_rfc3339};
#[cfg(feature = "unstable-locales")] #[cfg(feature = "unstable-locales")]
pub use locales::Locale; pub use locales::Locale;
#[cfg(not(feature = "unstable-locales"))] #[cfg(not(feature = "unstable-locales"))]