mirror of
https://github.com/chronotope/chrono.git
synced 2025-09-29 05:52:21 +00:00
Move SecondsFormat
from datetime
to format::formatting
This commit is contained in:
parent
5237de6e0a
commit
b7857baed2
@ -22,7 +22,7 @@ use crate::format::{
|
||||
StrftimeItems, TOO_LONG,
|
||||
};
|
||||
#[cfg(feature = "alloc")]
|
||||
use crate::format::{write_rfc2822, write_rfc3339, DelayedFormat};
|
||||
use crate::format::{write_rfc2822, write_rfc3339, DelayedFormat, SecondsFormat};
|
||||
use crate::naive::{Days, IsoWeek, NaiveDate, NaiveDateTime, NaiveTime};
|
||||
#[cfg(feature = "clock")]
|
||||
use crate::offset::Local;
|
||||
@ -44,38 +44,6 @@ pub(super) mod serde;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
/// Specific formatting options for seconds. This may be extended in the
|
||||
/// future, so exhaustive matching in external code is not recommended.
|
||||
///
|
||||
/// See the `TimeZone::to_rfc3339_opts` function for usage.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||
#[allow(clippy::manual_non_exhaustive)]
|
||||
pub enum SecondsFormat {
|
||||
/// Format whole seconds only, with no decimal point nor subseconds.
|
||||
Secs,
|
||||
|
||||
/// Use fixed 3 subsecond digits. This corresponds to
|
||||
/// [Fixed::Nanosecond3](format/enum.Fixed.html#variant.Nanosecond3).
|
||||
Millis,
|
||||
|
||||
/// Use fixed 6 subsecond digits. This corresponds to
|
||||
/// [Fixed::Nanosecond6](format/enum.Fixed.html#variant.Nanosecond6).
|
||||
Micros,
|
||||
|
||||
/// Use fixed 9 subsecond digits. This corresponds to
|
||||
/// [Fixed::Nanosecond9](format/enum.Fixed.html#variant.Nanosecond9).
|
||||
Nanos,
|
||||
|
||||
/// Automatically select one of `Secs`, `Millis`, `Micros`, or `Nanos` to
|
||||
/// display all available non-zero sub-second digits. This corresponds to
|
||||
/// [Fixed::Nanosecond](format/enum.Fixed.html#variant.Nanosecond).
|
||||
AutoSi,
|
||||
|
||||
// Do not match against this.
|
||||
#[doc(hidden)]
|
||||
__NonExhaustive,
|
||||
}
|
||||
|
||||
/// ISO 8601 combined date and time with time zone.
|
||||
///
|
||||
/// There are some constructors implemented here (the `from_*` methods), but
|
||||
|
@ -1,4 +1,5 @@
|
||||
use super::{DateTime, SecondsFormat};
|
||||
use super::DateTime;
|
||||
use crate::format::SecondsFormat;
|
||||
#[cfg(feature = "clock")]
|
||||
use crate::offset::Local;
|
||||
use crate::offset::{FixedOffset, LocalResult, TimeZone, Utc};
|
||||
|
@ -1,8 +1,8 @@
|
||||
use core::fmt;
|
||||
use serde::{de, ser};
|
||||
|
||||
use super::{DateTime, SecondsFormat};
|
||||
use crate::format::write_rfc3339;
|
||||
use super::DateTime;
|
||||
use crate::format::{write_rfc3339, SecondsFormat};
|
||||
use crate::naive::datetime::serde::serde_from;
|
||||
#[cfg(feature = "clock")]
|
||||
use crate::offset::Local;
|
||||
|
@ -11,8 +11,6 @@ use core::borrow::Borrow;
|
||||
use core::fmt::Display;
|
||||
use core::fmt::{self, Write};
|
||||
|
||||
#[cfg(any(feature = "alloc", feature = "serde", feature = "rustc-serialize"))]
|
||||
use crate::datetime::SecondsFormat;
|
||||
#[cfg(feature = "alloc")]
|
||||
use crate::offset::Offset;
|
||||
#[cfg(any(feature = "alloc", feature = "serde", feature = "rustc-serialize"))]
|
||||
@ -504,6 +502,38 @@ impl OffsetFormat {
|
||||
}
|
||||
}
|
||||
|
||||
/// Specific formatting options for seconds. This may be extended in the
|
||||
/// future, so exhaustive matching in external code is not recommended.
|
||||
///
|
||||
/// See the `TimeZone::to_rfc3339_opts` function for usage.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||
#[allow(clippy::manual_non_exhaustive)]
|
||||
pub enum SecondsFormat {
|
||||
/// Format whole seconds only, with no decimal point nor subseconds.
|
||||
Secs,
|
||||
|
||||
/// Use fixed 3 subsecond digits. This corresponds to
|
||||
/// [Fixed::Nanosecond3](format/enum.Fixed.html#variant.Nanosecond3).
|
||||
Millis,
|
||||
|
||||
/// Use fixed 6 subsecond digits. This corresponds to
|
||||
/// [Fixed::Nanosecond6](format/enum.Fixed.html#variant.Nanosecond6).
|
||||
Micros,
|
||||
|
||||
/// Use fixed 9 subsecond digits. This corresponds to
|
||||
/// [Fixed::Nanosecond9](format/enum.Fixed.html#variant.Nanosecond9).
|
||||
Nanos,
|
||||
|
||||
/// Automatically select one of `Secs`, `Millis`, `Micros`, or `Nanos` to
|
||||
/// display all available non-zero sub-second digits. This corresponds to
|
||||
/// [Fixed::Nanosecond](format/enum.Fixed.html#variant.Nanosecond).
|
||||
AutoSi,
|
||||
|
||||
// Do not match against this.
|
||||
#[doc(hidden)]
|
||||
__NonExhaustive,
|
||||
}
|
||||
|
||||
/// Writes the date, time and offset to the string. same as `%Y-%m-%dT%H:%M:%S%.f%:z`
|
||||
#[inline]
|
||||
#[cfg(any(feature = "alloc", feature = "serde", feature = "rustc-serialize"))]
|
||||
|
@ -58,6 +58,7 @@ pub(crate) use formatting::write_hundreds;
|
||||
pub(crate) use formatting::write_rfc2822;
|
||||
#[cfg(any(feature = "alloc", feature = "serde", feature = "rustc-serialize"))]
|
||||
pub(crate) use formatting::write_rfc3339;
|
||||
pub use formatting::SecondsFormat;
|
||||
#[cfg(feature = "alloc")]
|
||||
#[allow(deprecated)]
|
||||
pub use formatting::{format, format_item, DelayedFormat};
|
||||
|
@ -511,13 +511,13 @@ pub use datetime::rustc_serialize::TsSeconds;
|
||||
pub use datetime::DateTime;
|
||||
#[allow(deprecated)]
|
||||
#[doc(no_inline)]
|
||||
pub use datetime::{SecondsFormat, MAX_DATETIME, MIN_DATETIME};
|
||||
pub use datetime::{MAX_DATETIME, MIN_DATETIME};
|
||||
|
||||
pub mod format;
|
||||
/// L10n locales.
|
||||
#[cfg(feature = "unstable-locales")]
|
||||
pub use format::Locale;
|
||||
pub use format::{ParseError, ParseResult};
|
||||
pub use format::{ParseError, ParseResult, SecondsFormat};
|
||||
|
||||
pub mod naive;
|
||||
#[doc(inline)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user