sdispater / pendulum

Python datetimes made easy
https://pendulum.eustace.io
MIT License
6.22k stars 385 forks source link

Dates for "Etc/GMT(+/-)" show opposite timezones #557

Open fAhRenHeiT01 opened 3 years ago

fAhRenHeiT01 commented 3 years ago

Issue/Bug:

pendulum.from_format('2021-07-30 09:00 AM Etc/GMT+3', fmt='YYYY-MM-DD HH:mm A z') This will give the date in T-03:00 zone which is essentially GMT-3 instead of GMT+3

senpos commented 3 years ago

Interesting, can't reproduce it on my computer.

I am running Windows 10 too and the latest pendulum too.

>>> pendulum.__version__
'2.1.2'
>>> pendulum.from_format('2021-07-30 09:00 AM Etc/GMT+3', fmt='YYYY-MM-DD HH:mm A z')
DateTime(2021, 7, 30, 9, 0, 0, tzinfo=Timezone('Etc/GMT+3'))
faulander commented 3 years ago

On Ubuntu 20.02 it reports it correctly too: DateTime(2021, 7, 30, 9, 0, 0, tzinfo=Timezone('Etc/GMT+3'))

fAhRenHeiT01 commented 3 years ago

Yeah,

It's bizzare. If you want I can share the variabl states with you or discuss it over conference.

Thanks, Archit

On Wed, 30 Jun, 2021, 8:38 pm Faulander, @.***> wrote:

On Ubuntu 20.02 it reports it correctly too: DateTime(2021, 7, 30, 9, 0, 0, tzinfo=Timezone('Etc/GMT+3'))

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sdispater/pendulum/issues/557#issuecomment-871487459, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP4KCCWS4BHDXFYLDUSFDBLTVMXP5ANCNFSM47SCX32A .

fAhRenHeiT01 commented 3 years ago

And btw timezone info shows correct as you have mentioned but the actual time will be T- for GMT+ and T+ for GMT- like 2021-07-30T09:00-03:00 for GMT+3

On Wed, 30 Jun, 2021, 8:38 pm Faulander, @.***> wrote:

On Ubuntu 20.02 it reports it correctly too: DateTime(2021, 7, 30, 9, 0, 0, tzinfo=Timezone('Etc/GMT+3'))

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sdispater/pendulum/issues/557#issuecomment-871487459, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP4KCCWS4BHDXFYLDUSFDBLTVMXP5ANCNFSM47SCX32A .

robjhornby commented 3 years ago

The IANA timezone Etc/GMT+3 is defined as a UTC offset of -03:00 - Wikipedia page; the original source is the IANA database. i.e. I don't think this is a bug

fAhRenHeiT01 commented 3 years ago

Hi,

Thanks for sharing this and I hope you are doing well.

Got it. Although it makes sense, but for practical purposes, general understanding of time zones is wrt UTC/GMT +/- timezones.

I feel that there can be non-inverted versions along with the Etc versions which will basically go hand in hand with generic time conversions, don't you think?

Regards, Archit

On Sun, 29 Aug, 2021, 7:01 am robjhornby, @.***> wrote:

The IANA timezone Etc/GMT+3 is defined as a UTC offset of -03:00 - Wikipedia page https://en.wikipedia.org/wiki/List_of_tz_database_time_zones; the original source is the IANA database https://www.iana.org/time-zones. i.e. I don't think this is a bug

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sdispater/pendulum/issues/557#issuecomment-907713590, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP4KCCQ7RFYIXOOQAVXJLA3T7GEWLANCNFSM47SCX32A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

robjhornby commented 3 years ago

Hope you're doing well too. I'm not affiliated with Pendulum by the way.

I agree it's odd and can be confusing that Etc/GMT+x is the other way round. At least the Etc/ makes it obvious it's from IANA. I personally avoid using it, but I know to use the IANA definition if I encounter it in the wild.

If you're in control of how the date strings are generated, you could use a timezone offset from UTC like +03:00 which has the more intuitive sign. The token to match that in Pendulum is Z instead of z.

>>> pendulum.from_format('2021-07-30 09:00 AM +03:00', fmt='YYYY-MM-DD HH:mm A Z')
2021-07-30T09:00:00+03:00

If you're not in control of where these datetime strings are coming from, and you're sure they should mean the opposite sign, then it's a bug in the source data and you'd have to do some custom data cleaning to fix it.