16
16
// under the License.
17
17
18
18
use crate :: error:: { ArrowError , Result } ;
19
- use chrono:: format:: Fixed :: { Nanosecond as FixedNanosecond , TimezoneOffsetColon } ;
20
- use chrono:: format:: Item :: { Fixed , Literal , Numeric } ;
21
- use chrono:: format:: Numeric :: Nanosecond ;
22
- use chrono:: format:: Pad :: Zero ;
19
+ use chrono:: format:: Fixed :: { Nanosecond , TimezoneOffsetColon } ;
20
+ use chrono:: format:: Item :: { Fixed , Literal } ;
23
21
use chrono:: format:: { Item , Parsed } ;
24
22
use chrono:: prelude:: * ;
25
23
@@ -107,7 +105,7 @@ pub fn string_to_timestamp_nanos(s: &str) -> Result<i64> {
107
105
// timezone offset, using ' ' as a separator
108
106
// Example: 2020-09-08 13:42:29.190855-05:00
109
107
// Full format string: "%Y-%m-%d %H:%M:%S%.f%:z".
110
- const FORMAT1 : [ Item ; 2 ] = [ Fixed ( FixedNanosecond ) , Fixed ( TimezoneOffsetColon ) ] ;
108
+ const FORMAT1 : [ Item ; 2 ] = [ Fixed ( Nanosecond ) , Fixed ( TimezoneOffsetColon ) ] ;
111
109
if let Ok ( ts) = chrono:: format:: parse ( & mut p, rest, FORMAT1 . iter ( ) )
112
110
. and_then ( |( ) | p. to_datetime ( ) )
113
111
{
@@ -117,7 +115,7 @@ pub fn string_to_timestamp_nanos(s: &str) -> Result<i64> {
117
115
// with an explicit Z, using ' ' as a separator
118
116
// Example: 2020-09-08 13:42:29Z
119
117
// Full format string: "%Y-%m-%d %H:%M:%S%.fZ".
120
- const FORMAT2 : [ Item ; 2 ] = [ Fixed ( FixedNanosecond ) , Literal ( "Z" ) ] ;
118
+ const FORMAT2 : [ Item ; 2 ] = [ Fixed ( Nanosecond ) , Literal ( "Z" ) ] ;
121
119
if let Ok ( ts) = chrono:: format:: parse ( & mut p, rest, FORMAT2 . iter ( ) )
122
120
. and_then ( |( ) | p. to_datetime_with_timezone ( & Utc ) )
123
121
{
@@ -126,8 +124,8 @@ pub fn string_to_timestamp_nanos(s: &str) -> Result<i64> {
126
124
127
125
// without a timezone specifier as a local time, using ' ' as a separator
128
126
// Example: 2020-09-08 13:42:29.190855
129
- const FORMAT5 : [ Item ; 2 ] = [ Literal ( "." ) , Numeric ( Nanosecond , Zero ) ] ;
130
- // Full format string: "%Y-%m-%d %H:%M:%S.% f".
127
+ const FORMAT5 : [ Item ; 1 ] = [ Fixed ( Nanosecond ) ] ;
128
+ // Full format string: "%Y-%m-%d %H:%M:%S%. f".
131
129
if let Ok ( ts) = chrono:: format:: parse ( & mut p, rest, FORMAT5 . iter ( ) )
132
130
. and_then ( |( ) | p. to_naive_datetime_with_offset ( 0 ) )
133
131
{
@@ -152,8 +150,8 @@ pub fn string_to_timestamp_nanos(s: &str) -> Result<i64> {
152
150
{
153
151
// without a timezone specifier as a local time, using T as a separator
154
152
// Example: 2020-09-08T13:42:29.190855
155
- // Full format string: "%Y-%m-%dT%H:%M:%S.% f".
156
- const FORMAT3 : [ Item ; 2 ] = [ Literal ( "." ) , Numeric ( Nanosecond , Zero ) ] ;
153
+ // Full format string: "%Y-%m-%dT%H:%M:%S%. f".
154
+ const FORMAT3 : [ Item ; 1 ] = [ Fixed ( Nanosecond ) ] ;
157
155
if let Ok ( ts) = chrono:: format:: parse ( & mut p, rest, FORMAT3 . iter ( ) )
158
156
. and_then ( |( ) | p. to_naive_datetime_with_offset ( 0 ) )
159
157
{
0 commit comments