Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/items/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use chrono::{DateTime, Datelike, FixedOffset, NaiveDate, TimeZone, Timelike};

use super::{date, relative, time, weekday, year};
use super::{date, relative, time, timezone, weekday, year};

/// The builder is used to construct a DateTime object from various components.
/// The parser creates a `DateTimeBuilder` object with the parsed components,
Expand All @@ -17,7 +17,7 @@ pub(crate) struct DateTimeBuilder {
date: Option<date::Date>,
time: Option<time::Time>,
weekday: Option<weekday::Weekday>,
timezone: Option<time::Offset>,
timezone: Option<timezone::Offset>,
relative: Vec<relative::Relative>,
}

Expand Down Expand Up @@ -86,7 +86,7 @@ impl DateTimeBuilder {
Ok(self)
}

pub(super) fn set_timezone(mut self, timezone: time::Offset) -> Result<Self, &'static str> {
pub(super) fn set_timezone(mut self, timezone: timezone::Offset) -> Result<Self, &'static str> {
if self.timestamp.is_some() {
return Err("timestamp cannot be combined with other date/time items");
} else if self.timezone.is_some() {
Expand Down Expand Up @@ -338,7 +338,7 @@ fn new_date(
/// Restores year, month, day, etc after applying the timezone
/// returns None if timezone overflows the date
fn with_timezone_restore(
offset: time::Offset,
offset: timezone::Offset,
at: DateTime<FixedOffset>,
) -> Option<DateTime<FixedOffset>> {
let offset: FixedOffset = chrono::FixedOffset::try_from(offset).ok()?;
Expand Down
2 changes: 1 addition & 1 deletion src/items/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(crate) enum Item {
Time(time::Time),
Weekday(weekday::Weekday),
Relative(relative::Relative),
TimeZone(time::Offset),
TimeZone(timezone::Offset),
Pure(String),
}

Expand Down
8 changes: 8 additions & 0 deletions src/items/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ where
.parse_next(input)
}

/// Parse a colon preceded by whitespace
pub(super) fn colon<'a, E>(input: &mut &'a str) -> winnow::Result<(), E>
where
E: ParserError<&'a str>,
{
s(':').void().parse_next(input)
}

/// Create a context error with a reason.
pub(super) fn ctx_err(reason: &'static str) -> ContextError {
let mut err = ContextError::new();
Expand Down
Loading
Loading