1
- use super :: { timezone, unit:: PoSQLTimeUnit } ;
2
- use crate :: error:: PoSQLTimestampError ;
1
+ use super :: { PoSQLTimeUnit , PoSQLTimeZone , PoSQLTimestampError } ;
3
2
use chrono:: { offset:: LocalResult , DateTime , TimeZone , Utc } ;
4
3
use serde:: { Deserialize , Serialize } ;
5
4
@@ -13,7 +12,7 @@ pub struct PoSQLTimestamp {
13
12
pub timeunit : PoSQLTimeUnit ,
14
13
15
14
/// The timezone of the datetime, either UTC or a fixed offset from UTC.
16
- pub timezone : timezone :: PoSQLTimeZone ,
15
+ pub timezone : PoSQLTimeZone ,
17
16
}
18
17
19
18
impl PoSQLTimestamp {
@@ -32,7 +31,7 @@ impl PoSQLTimestamp {
32
31
/// # Examples
33
32
/// ```
34
33
/// use chrono::{DateTime, Utc};
35
- /// use proof_of_sql_parser::posql_time::{timestamp:: PoSQLTimestamp, timezone:: PoSQLTimeZone};
34
+ /// use proof_of_sql_parser::posql_time::{PoSQLTimestamp, PoSQLTimeZone};
36
35
///
37
36
/// // Parsing an RFC 3339 timestamp without a timezone:
38
37
/// let timestamp_str = "2009-01-03T18:15:05Z";
@@ -49,7 +48,7 @@ impl PoSQLTimestamp {
49
48
. map_err ( |e| PoSQLTimestampError :: ParsingError ( e. to_string ( ) ) ) ?;
50
49
51
50
let offset_seconds = dt. offset ( ) . local_minus_utc ( ) ;
52
- let timezone = timezone :: PoSQLTimeZone :: from_offset ( offset_seconds) ;
51
+ let timezone = PoSQLTimeZone :: from_offset ( offset_seconds) ;
53
52
let nanoseconds = dt. timestamp_subsec_nanos ( ) ;
54
53
let timeunit = if nanoseconds % 1_000 != 0 {
55
54
PoSQLTimeUnit :: Nanosecond
@@ -78,7 +77,7 @@ impl PoSQLTimestamp {
78
77
/// # Examples
79
78
/// ```
80
79
/// use chrono::{DateTime, Utc};
81
- /// use proof_of_sql_parser::posql_time::{timestamp:: PoSQLTimestamp, timezone:: PoSQLTimeZone};
80
+ /// use proof_of_sql_parser::posql_time::{PoSQLTimestamp, PoSQLTimeZone};
82
81
///
83
82
/// // Parsing a Unix epoch timestamp (assumed to be seconds and UTC):
84
83
/// let unix_time = 1231006505;
@@ -90,7 +89,7 @@ impl PoSQLTimestamp {
90
89
LocalResult :: Single ( timestamp) => Ok ( PoSQLTimestamp {
91
90
timestamp,
92
91
timeunit : PoSQLTimeUnit :: Second ,
93
- timezone : timezone :: PoSQLTimeZone :: Utc ,
92
+ timezone : PoSQLTimeZone :: Utc ,
94
93
} ) ,
95
94
LocalResult :: Ambiguous ( earliest, latest) => Err ( PoSQLTimestampError :: Ambiguous (
96
95
format ! ( "The local time is ambiguous because there is a fold in the local time: earliest: {} latest: {} " , earliest, latest) ,
@@ -107,7 +106,7 @@ mod tests {
107
106
#[ test]
108
107
fn test_unix_epoch_time_timezone ( ) {
109
108
let unix_time = 1231006505 ; // Unix time as string
110
- let expected_timezone = timezone :: PoSQLTimeZone :: Utc ; // Unix time should always be UTC
109
+ let expected_timezone = PoSQLTimeZone :: Utc ; // Unix time should always be UTC
111
110
let result = PoSQLTimestamp :: to_timestamp ( unix_time) . unwrap ( ) ;
112
111
assert_eq ! ( result. timezone, expected_timezone) ;
113
112
}
0 commit comments