feat!: parsing local timestamp (#1352)

* fix: parse and display timestamp/datetime in local time zone

* fix display

* fix: unit tests

* change time zone env

* fix: remove useless code
This commit is contained in:
Lei, HUANG
2023-04-11 12:54:15 +08:00
committed by GitHub
parent 1a21a6ea41
commit f5cf5685cc
8 changed files with 100 additions and 33 deletions

View File

@@ -487,15 +487,16 @@ mod tests {
#[test]
pub fn test_parse_datetime_literal() {
std::env::set_var("TZ", "Asia/Shanghai");
let value = sql_value_to_value(
"datetime_col",
&ConcreteDataType::datetime_datatype(),
&SqlValue::DoubleQuotedString("2022-02-22 00:01:03".to_string()),
&SqlValue::DoubleQuotedString("2022-02-22 00:01:03+0800".to_string()),
)
.unwrap();
assert_eq!(ConcreteDataType::datetime_datatype(), value.data_type());
if let Value::DateTime(d) = value {
assert_eq!("2022-02-22 00:01:03", d.to_string());
assert_eq!("2022-02-22 00:01:03+0800", d.to_string());
} else {
unreachable!()
}