@@ -57,7 +57,7 @@ use winnow::{
57
57
use crate :: ParseDateTimeError ;
58
58
59
59
#[ derive( PartialEq , Debug ) ]
60
- pub ( crate ) enum Item {
60
+ enum Item {
61
61
Timestamp ( epoch:: Timestamp ) ,
62
62
DateTime ( combined:: DateTime ) ,
63
63
Date ( date:: Date ) ,
@@ -68,8 +68,29 @@ pub(crate) enum Item {
68
68
Pure ( String ) ,
69
69
}
70
70
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
+
71
92
/// 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 > {
73
94
builder
74
95
. set_base ( base)
75
96
. build ( )
@@ -78,7 +99,7 @@ pub(crate) fn at_date(builder: DateTimeBuilder, base: Zoned) -> Result<Zoned, Pa
78
99
79
100
/// Build a `Zoned` object from a `DateTimeBuilder` and a default `Zoned` object
80
101
/// (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 > {
82
103
builder. build ( ) . ok_or ( ParseDateTimeError :: InvalidInput )
83
104
}
84
105
@@ -177,7 +198,7 @@ pub(crate) fn at_local(builder: DateTimeBuilder) -> Result<Zoned, ParseDateTimeE
177
198
///
178
199
/// optional_whitespace = { whitespace } ;
179
200
/// ```
180
- pub ( crate ) fn parse ( input : & mut & str ) -> ModalResult < DateTimeBuilder > {
201
+ fn parse ( input : & mut & str ) -> ModalResult < DateTimeBuilder > {
181
202
trace ( "parse" , alt ( ( parse_timestamp, parse_items) ) ) . parse_next ( input)
182
203
}
183
204
0 commit comments