Skip to content

prettyprint to show timezone offset for timestamp with timezone #2937

@waitingkuo

Description

@waitingkuo

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

I'd like to print timezone offset when the timestamp contains timezone

Describe the solution you'd like

i would like this

use arrow::array::{
    Array, TimestampSecondArray,
};
use arrow::datatypes::*;
use arrow::record_batch::RecordBatch;
use std::sync::Arc;

use arrow::util::pretty::print_batches;

fn main() {


    let arr = TimestampSecondArray::from_vec(vec![0], Some("+08:00".to_string()));
    let schema = Arc::new(Schema::new(vec![Field::new(
        "f",
        arr.data_type().clone(),
        true,
    )]));

    let batch = RecordBatch::try_new(schema, vec![Arc::new(arr)]).unwrap();
    print_batches(&[batch]).unwrap();
}

to output

+---------------------------+
| f                         |
+---------------------------+
| 1970-01-01T08:00:00+08:00 |
+---------------------------+

instead of

+---------------------+
| f                   |
+---------------------+
| 1970-01-01 00:00:00 |
+---------------------+

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changelog

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions