Skip to content

pendulum.instance() incorrectly converts timezone to "+00:00" instead of "UTC" #555

@ecerulm

Description

@ecerulm
  • I am on the latest Pendulum version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: macOS Big Sur
  • Pendulum version: 2.1.2

Issue

from datetime import datetime,timezone

dt = datetime(2019, 8, 1, tzinfo=timezone.utc) # datetime.datetime(2019, 8, 1, 0, 0, tzinfo=datetime.timezone.utc)
pdt = pendulum.instance(dt) # DateTime(2019, 8, 1, 0, 0, 0, tzinfo=Timezone('+00:00'))

the timezone returned is Timezone('+00:00') instead of the expected Timezone('UTC') this is not consistent with the behaviour of the pendulum.datetime constructor:

pdt2 = pendulum.datetime(2019, 8, 1, tz=timezone.utc) #  DateTime(2019, 8, 1, 0, 0, 0, tzinfo=Timezone('UTC'))

So the same original timezone timezone.utc is converted to Timezone('+00:00') by pendulum.instance() and to Timezone('UTC') by pendulum.datetime.

I consider that timezone.utc should be always interpreted as pendulum.timezone('UTC')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions