Skip to content

Commit

Permalink
chore: doc
Browse files Browse the repository at this point in the history
  • Loading branch information
appletreeisyellow committed Jul 9, 2024
1 parent 4b4620a commit f0a1cf4
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions datafusion/functions/src/datetime/to_local_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,35 +248,7 @@ impl ToLocalTimeFunc {
/// 2019-03-31T01:00:00
/// ```
///
/// # Example
///
/// ```
/// # use chrono::NaiveDateTime;
/// # use arrow::array::types::TimestampNanosecondType;
/// # use datafusion_functions::datetime::to_local_time::adjust_to_local_time;
///
/// let timestamp_str = "2020-03-31T13:40:00";
/// let tz: arrow::array::timezone::Tz =
/// "America/New_York".parse().expect("Invalid timezone");
///
/// let timestamp = timestamp_str
/// .parse::<NaiveDateTime>()
/// .unwrap()
/// .and_local_timezone(tz) // this is in a local timezone
/// .unwrap()
/// .timestamp_nanos_opt()
/// .unwrap();
///
/// let expected_timestamp = timestamp_str
/// .parse::<NaiveDateTime>()
/// .unwrap()
/// .and_utc() // this is in UTC
/// .timestamp_nanos_opt()
/// .unwrap();
///
/// let res = adjust_to_local_time::<TimestampNanosecondType>(timestamp, tz);
/// assert_eq!(res, expected_timestamp);
/// ```
/// See `test_adjust_to_local_time()` for example
fn adjust_to_local_time<T: ArrowTimestampType>(ts: i64, tz: Tz) -> i64 {
let date_time = match T::UNIT {
Nanosecond => Utc.timestamp_nanos(ts),
Expand Down

0 comments on commit f0a1cf4

Please sign in to comment.