@@ -57,7 +57,7 @@ use winnow::{
5757use crate :: ParseDateTimeError ;
5858
5959#[ derive( PartialEq , Debug ) ]
60- pub ( crate ) enum Item {
60+ enum Item {
6161 Timestamp ( epoch:: Timestamp ) ,
6262 DateTime ( combined:: DateTime ) ,
6363 Date ( date:: Date ) ,
@@ -68,8 +68,29 @@ pub(crate) enum Item {
6868 Pure ( String ) ,
6969}
7070
71+ /// Parse a date and time string based on a specific date.
72+ pub ( crate ) fn parse_at_date < S : AsRef < str > + Clone > (
73+ base : Zoned ,
74+ input : S ,
75+ ) -> Result < Zoned , ParseDateTimeError > {
76+ let input = input. as_ref ( ) . to_ascii_lowercase ( ) ;
77+ match parse ( & mut input. as_str ( ) ) {
78+ Ok ( builder) => at_date ( builder, base) ,
79+ Err ( _) => Err ( ParseDateTimeError :: InvalidInput ) ,
80+ }
81+ }
82+
83+ /// Parse a date and time string based on the current local time.
84+ pub ( crate ) fn parse_at_local < S : AsRef < str > + Clone > ( input : S ) -> Result < Zoned , ParseDateTimeError > {
85+ let input = input. as_ref ( ) . to_ascii_lowercase ( ) ;
86+ match parse ( & mut input. as_str ( ) ) {
87+ Ok ( builder) => at_local ( builder) ,
88+ Err ( _) => Err ( ParseDateTimeError :: InvalidInput ) ,
89+ }
90+ }
91+
7192/// Build a `Zoned` object from a `DateTimeBuilder` and a base `Zoned` object.
72- pub ( crate ) fn at_date ( builder : DateTimeBuilder , base : Zoned ) -> Result < Zoned , ParseDateTimeError > {
93+ fn at_date ( builder : DateTimeBuilder , base : Zoned ) -> Result < Zoned , ParseDateTimeError > {
7394 builder
7495 . set_base ( base)
7596 . build ( )
@@ -78,7 +99,7 @@ pub(crate) fn at_date(builder: DateTimeBuilder, base: Zoned) -> Result<Zoned, Pa
7899
79100/// Build a `Zoned` object from a `DateTimeBuilder` and a default `Zoned` object
80101/// (the current time in the local timezone).
81- pub ( crate ) fn at_local ( builder : DateTimeBuilder ) -> Result < Zoned , ParseDateTimeError > {
102+ fn at_local ( builder : DateTimeBuilder ) -> Result < Zoned , ParseDateTimeError > {
82103 builder. build ( ) . ok_or ( ParseDateTimeError :: InvalidInput )
83104}
84105
@@ -177,7 +198,7 @@ pub(crate) fn at_local(builder: DateTimeBuilder) -> Result<Zoned, ParseDateTimeE
177198///
178199/// optional_whitespace = { whitespace } ;
179200/// ```
180- pub ( crate ) fn parse ( input : & mut & str ) -> ModalResult < DateTimeBuilder > {
201+ fn parse ( input : & mut & str ) -> ModalResult < DateTimeBuilder > {
181202 trace ( "parse" , alt ( ( parse_timestamp, parse_items) ) ) . parse_next ( input)
182203}
183204
0 commit comments