Skip to content

Commit d9d6b63

Browse files
committed
Move Days to naive module
1 parent 41be21e commit d9d6b63

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/naive/date/mod.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::format::{
3333
Parsed, StrftimeItems,
3434
};
3535
use crate::month::Months;
36-
use crate::naive::{IsoWeek, NaiveDateTime, NaiveTime, NaiveWeek};
36+
use crate::naive::{Days, IsoWeek, NaiveDateTime, NaiveTime, NaiveWeek};
3737
use crate::{expect, try_opt};
3838
use crate::{Datelike, TimeDelta, Weekday};
3939

@@ -42,22 +42,6 @@ use super::internals::{Mdf, YearFlags};
4242
#[cfg(test)]
4343
mod tests;
4444

45-
/// A duration in calendar days.
46-
///
47-
/// This is useful because when using `TimeDelta` it is possible that adding `TimeDelta::days(1)`
48-
/// doesn't increment the day value as expected due to it being a fixed number of seconds. This
49-
/// difference applies only when dealing with `DateTime<TimeZone>` data types and in other cases
50-
/// `TimeDelta::days(n)` and `Days::new(n)` are equivalent.
51-
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
52-
pub struct Days(pub(crate) u64);
53-
54-
impl Days {
55-
/// Construct a new `Days` from a number of days
56-
pub const fn new(num: u64) -> Self {
57-
Self(num)
58-
}
59-
}
60-
6145
/// ISO 8601 calendar date without timezone.
6246
/// Allows for every [proleptic Gregorian date] from Jan 1, 262145 BCE to Dec 31, 262143 CE.
6347
/// Also supports the conversion from ISO 8601 ordinal and week date.

src/naive/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod internals;
1515
pub(crate) mod isoweek;
1616
pub(crate) mod time;
1717

18-
pub use self::date::{Days, NaiveDate, NaiveDateDaysIterator, NaiveDateWeeksIterator};
18+
pub use self::date::{NaiveDate, NaiveDateDaysIterator, NaiveDateWeeksIterator};
1919
#[allow(deprecated)]
2020
pub use self::date::{MAX_DATE, MIN_DATE};
2121
#[cfg(feature = "rustc-serialize")]
@@ -125,6 +125,22 @@ impl NaiveWeek {
125125
}
126126
}
127127

128+
/// A duration in calendar days.
129+
///
130+
/// This is useful because when using `TimeDelta` it is possible that adding `TimeDelta::days(1)`
131+
/// doesn't increment the day value as expected due to it being a fixed number of seconds. This
132+
/// difference applies only when dealing with `DateTime<TimeZone>` data types and in other cases
133+
/// `TimeDelta::days(n)` and `Days::new(n)` are equivalent.
134+
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
135+
pub struct Days(pub(crate) u64);
136+
137+
impl Days {
138+
/// Construct a new `Days` from a number of days
139+
pub const fn new(num: u64) -> Self {
140+
Self(num)
141+
}
142+
}
143+
128144
/// Serialization/Deserialization of naive types in alternate formats
129145
///
130146
/// The various modules in here are intended to be used with serde's [`with`

0 commit comments

Comments
 (0)