tustvold commented on code in PR #4581:
URL: https://github.com/apache/arrow-rs/pull/4581#discussion_r1278294588
##########
arrow-cast/src/display.rs:
##########
@@ -68,64 +76,79 @@ impl<'a> Default for FormatOptions<'a> {
timestamp_format: None,
timestamp_tz_format: None,
time_format: None,
+ iso8601_duration_format: true,
}
}
-}
-impl<'a> FormatOptions<'a> {
/// If set to `true` any formatting errors will be written to the output
/// instead of being converted into a [`std::fmt::Error`]
- pub fn with_display_error(mut self, safe: bool) -> Self {
+ pub const fn with_display_error(mut self, safe: bool) -> Self {
self.safe = safe;
self
}
/// Overrides the string used to represent a null
///
/// Defaults to `""`
- pub fn with_null(self, null: &'a str) -> Self {
+ pub const fn with_null(self, null: &'a str) -> Self {
Self { null, ..self }
}
/// Overrides the format used for [`DataType::Date32`] columns
- pub fn with_date_format(self, date_format: Option<&'a str>) -> Self {
+ pub const fn with_date_format(self, date_format: Option<&'a str>) -> Self {
Self {
date_format,
..self
}
}
/// Overrides the format used for [`DataType::Date64`] columns
- pub fn with_datetime_format(self, datetime_format: Option<&'a str>) ->
Self {
+ pub const fn with_datetime_format(self, datetime_format: Option<&'a str>)
-> Self {
Self {
datetime_format,
..self
}
}
/// Overrides the format used for [`DataType::Timestamp`] columns without
a timezone
- pub fn with_timestamp_format(self, timestamp_format: Option<&'a str>) ->
Self {
+ pub const fn with_timestamp_format(self, timestamp_format: Option<&'a
str>) -> Self {
Self {
timestamp_format,
..self
}
}
/// Overrides the format used for [`DataType::Timestamp`] columns with a
timezone
- pub fn with_timestamp_tz_format(self, timestamp_tz_format: Option<&'a
str>) -> Self {
+ pub const fn with_timestamp_tz_format(
+ self,
+ timestamp_tz_format: Option<&'a str>,
+ ) -> Self {
Self {
timestamp_tz_format,
..self
}
}
/// Overrides the format used for [`DataType::Time32`] and
[`DataType::Time64`] columns
- pub fn with_time_format(self, time_format: Option<&'a str>) -> Self {
+ pub const fn with_time_format(self, time_format: Option<&'a str>) -> Self {
Self {
time_format,
..self
}
}
+
+ /// If true formats durations as ISO8601, otherwise prints a human
readable format
+ ///
+ /// * ISO 8601 - "P198DT72932.972880S"
+ /// * Human Readable - "198 days 16 hours 34 mins 15.407810000 secs"
+ ///
+ /// Defaults to true
+ pub const fn with_iso8601_duration_format(self, iso8601: bool) -> Self {
Review Comment:
I could see us also adding an option to print intervals as ISO8601
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]