arrow icon indicating copy to clipboard operation
arrow copied to clipboard

incorrect tzinfo when arrow.get()

Open da-head0 opened this issue 1 year ago • 4 comments

Issue Description

when I add tzinfo as

end_time_as_cron = '1 10 4 3 *' # linux cron expression
arrow.get(end_time_as_cron, 'm H D M [*]', tzinfo='ASIA/Seoul')

the result is

end time:  0001-03-04T10:01:00+08:27:52

The timezone is not +09:00.

System Info

  • 🖥 OS name and version: MacOS 12.3. and jupyter notebook 6.5.4-->
  • 🐍 Python version: Python 3.10.8
  • 🏹 Arrow version: 1.2.3

Thanks in advance.

da-head0 avatar Apr 27 '23 02:04 da-head0

I believe this has to do with the format you are passing, will take a deeper look, but the following works correctly:

arrow.get('2020-01-01T02:03:01', tzinfo='Asia/Seoul')
<Arrow [2020-01-01T02:03:01+09:00]>

krisfremen avatar Apr 29 '23 01:04 krisfremen

That is actually some strange behavior, I will need to dig deeper to see what can be done.

krisfremen avatar Apr 29 '23 03:04 krisfremen

Odd one for sure. Add year and it'll work.

end_time_as_cron = '2020 1 10 4 3 [*]' # linux cron expression
arrow.get(end_time_as_cron, 'YYYY m H D M [*]', tzinfo='Asia/Seoul')
<Arrow [2020-03-04T10:01:00+09:00]>

edit The plot thickens. I can only reproduce with Asia/Seoul

>>> end_time_as_cron = '1 10 4 3' # linux cron expression
>>> arrow.get(end_time_as_cron, 'm H D M', tzinfo='America/Los_Angeles')
<Arrow [0001-03-04T10:01:00-08:00]>
>>> arrow.get(end_time_as_cron, 'm H D M', tzinfo='Asia/Seoul')
<Arrow [0001-03-04T10:01:00+08:27:52]>
>>> arrow.get(end_time_as_cron, 'm H D M', tzinfo='Europe/Vienna')
<Arrow [0001-03-04T10:01:00+01:00]>
>>>

Datetime.datetime has the same behavior

>>> datetime.datetime(
            1, 2, 2, 12, 30, 45, 999999, tzinfo=pytz.timezone("Asia/Seoul")
        )
datetime.datetime(1, 2, 2, 12, 30, 45, 999999, tzinfo=<DstTzInfo 'Asia/Seoul' LMT+8:28:00 STD>)

andrewelkins avatar Jul 19 '23 03:07 andrewelkins

Found it. It's hinted in that datetime response. LMT which explains why using a more recent year "fixes" it. https://blog.qax.io/pytz-and-strange-timezones/ https://en.wikipedia.org/wiki/Local_mean_time

andrewelkins avatar Jul 19 '23 04:07 andrewelkins