Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
stay complient with arrow spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Sep 27, 2021
1 parent 99a12aa commit 9784618
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/io/csv/write/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@ use super::iterator::{BufStreamingIterator, StreamingIterator};

#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub struct SerializeOptions {
// used for date32
pub date_format: String,
/// used for date32
pub date32_format: String,
/// used for dat64
pub datetime_format: String,
// used for time32/64
pub time_format: String,
// used for timestamp
pub date64_format: String,
/// used for time32
pub time32_format: String,
/// used for time64
pub time64_format: String,
/// used for timestamp
pub timestamp_format: String,
}

impl Default for SerializeOptions {
fn default() -> Self {
Self {
date_format: "%F".to_string(),
datetime_format: "%FT%H:%M:%S.%9f".to_string(),
time_format: "%T".to_string(),
date32_format: "%F".to_string(),
date64_format: "%F".to_string(),
time32_format: "%T".to_string(),
time64_format: "%T".to_string(),
timestamp_format: "%FT%H:%M:%S.%9f".to_string(),
}
}
Expand Down Expand Up @@ -129,23 +132,23 @@ pub fn new_serializer<'a>(
i32,
temporal_conversions::date32_to_datetime,
array,
&options.date_format
&options.date32_format
)
}
DataType::Time32(TimeUnit::Second) => {
dyn_date!(
i32,
temporal_conversions::time32s_to_time,
array,
&options.time_format
&options.time32_format
)
}
DataType::Time32(TimeUnit::Millisecond) => {
dyn_date!(
i32,
temporal_conversions::time32ms_to_time,
array,
&options.time_format
&options.time32_format
)
}
DataType::Int64 => {
Expand All @@ -156,23 +159,23 @@ pub fn new_serializer<'a>(
i64,
temporal_conversions::date64_to_datetime,
array,
&options.datetime_format
&options.date64_format
)
}
DataType::Time64(TimeUnit::Microsecond) => {
dyn_date!(
i64,
temporal_conversions::time64us_to_time,
array,
&options.time_format
&options.time64_format
)
}
DataType::Time64(TimeUnit::Nanosecond) => {
dyn_date!(
i64,
temporal_conversions::time64ns_to_time,
array,
&options.time_format
&options.time64_format
)
}
DataType::Timestamp(TimeUnit::Second, None) => {
Expand Down

0 comments on commit 9784618

Please sign in to comment.