| 25 | // https://howardhinnant.github.io/date/tz.html#Examples |
| 26 | |
| 27 | class OffsetZone { |
| 28 | std::chrono::minutes offset_; |
| 29 | |
| 30 | public: |
| 31 | explicit OffsetZone(std::chrono::minutes offset) : offset_{offset} {} |
| 32 | |
| 33 | template <class Duration> |
| 34 | chrono::local_time<Duration> to_local(chrono::sys_time<Duration> tp) const { |
| 35 | return chrono::local_time<Duration>{(tp + offset_).time_since_epoch()}; |
| 36 | } |
| 37 | |
| 38 | template <class Duration> |
| 39 | chrono::sys_time<Duration> to_sys( |
| 40 | chrono::local_time<Duration> tp, |
| 41 | [[maybe_unused]] chrono::choose = chrono::choose::earliest) const { |
| 42 | return chrono::sys_time<Duration>{(tp - offset_).time_since_epoch()}; |
| 43 | } |
| 44 | |
| 45 | template <class Duration> |
| 46 | chrono::sys_info get_info(chrono::sys_time<Duration> st) const { |
| 47 | return {chrono::sys_seconds::min(), chrono::sys_seconds::max(), offset_, |
| 48 | std::chrono::minutes(0), |
| 49 | offset_ >= std::chrono::minutes(0) ? "+" + chrono::format("%H%M", offset_) |
| 50 | : "-" + chrono::format("%H%M", -offset_)}; |
| 51 | } |
| 52 | |
| 53 | const OffsetZone* operator->() const { return this; } |
| 54 | }; |
| 55 | |
| 56 | } // namespace arrow::internal |
| 57 | |