From 908356f3a3f0b44c7518622f780a986a129f3427 Mon Sep 17 00:00:00 2001 From: yuankunzhang Date: Wed, 6 Aug 2025 22:15:03 +0800 Subject: [PATCH] code and docs minor improvements --- src/items/builder.rs | 4 ++-- src/items/combined.rs | 10 +++------- src/items/epoch.rs | 14 ++++++++++++++ src/items/mod.rs | 3 +-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/items/builder.rs b/src/items/builder.rs index 23c6f5c..cac546f 100644 --- a/src/items/builder.rs +++ b/src/items/builder.rs @@ -11,7 +11,7 @@ use super::{date, relative, time, weekday, year}; /// date and time using the `set_base()` method before calling `build()`, or /// leave it unset to use the current date and time as the base. #[derive(Debug, Default)] -pub struct DateTimeBuilder { +pub(crate) struct DateTimeBuilder { base: Option>, timestamp: Option, date: Option, @@ -289,7 +289,7 @@ impl DateTimeBuilder { } } -#[allow(clippy::too_many_arguments)] +#[allow(clippy::too_many_arguments, deprecated)] fn new_date( year: i32, month: u32, diff --git a/src/items/combined.rs b/src/items/combined.rs index d83baf5..79bb248 100644 --- a/src/items/combined.rs +++ b/src/items/combined.rs @@ -21,16 +21,12 @@ use winnow::{ use crate::items::space; -use super::{ - date::{self, Date}, - primitive::s, - time::{self, Time}, -}; +use super::{date, primitive::s, time}; #[derive(PartialEq, Debug, Clone, Default)] pub(crate) struct DateTime { - pub(crate) date: Date, - pub(crate) time: Time, + pub(crate) date: date::Date, + pub(crate) time: time::Time, } pub(crate) fn parse(input: &mut &str) -> ModalResult { diff --git a/src/items/epoch.rs b/src/items/epoch.rs index 5cde089..7a44a23 100644 --- a/src/items/epoch.rs +++ b/src/items/epoch.rs @@ -1,6 +1,20 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. +//! From the GNU docs: +//! +//! > If you precede a number with ‘@’, it represents an internal timestamp as +//! > a count of seconds. The number can contain an internal decimal point +//! > (either ‘.’ or ‘,’); any excess precision not supported by the internal +//! > representation is truncated toward minus infinity. Such a number cannot +//! > be combined with any other date item, as it specifies a complete +//! > timestamp. +//! > +//! > On most hosts, these counts ignore the presence of leap seconds. For +//! > example, on most hosts ‘@1483228799’ represents 2016-12-31 23:59:59 UTC, +//! > ‘@1483228800’ represents 2017-01-01 00:00:00 UTC, and there is no way to +//! > represent the intervening leap second 2016-12-31 23:59:60 UTC. + use winnow::{combinator::preceded, ModalResult, Parser}; use super::primitive::{float, s}; diff --git a/src/items/mod.rs b/src/items/mod.rs index bd6784f..9e28d10 100644 --- a/src/items/mod.rs +++ b/src/items/mod.rs @@ -21,14 +21,13 @@ //! - [`combined`] //! - [`date`] //! - [`epoch`] +//! - [`pure`] //! - [`relative`] //! - [`time`] //! - [`timezone`] //! - [`weekday`] //! - [`year`] -#![allow(deprecated)] - // date and time items mod combined; mod date;