tustvold commented on PR #4201:
URL: https://github.com/apache/arrow-rs/pull/4201#issuecomment-1543889159

   Thank you for this, I'm not sure this logic is correct, however.
   
   If both quantities have timezones, no adjustment should be necessary, as 
they are already normalized to UTC.
   
   The complexity arises when converting between timestamps where one doesn't 
have a timezone. This requires some care, especially to handle timezones that 
don't have fixed offsets.
   
   In the forward direction I think this involves doing something like
   
   ```
   let from_tz = from_tz.parse()?;
   array.unary_opt(|i| {
       T::make_value(as_datetime_with_timezone(i, from_tz)?.naive_local())
   })
   ```
   
   And in the reverse direction
   
   ```
   let to_tz = to_tz.parse()?;
   array.unary_opt(|i| {
       let local = as_datetime(i);
       let offset = to_tz.offset_from_local_datetime(&local).single()?;
       T::make_value(local + offset.fix())
   })
   ```


-- 
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]

Reply via email to