Skip to content

breaking: from_format errors out when there is no local timezone configuration but timezone is passed in #613

Open
@ayoung19

Description

@ayoung19
  • 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: This is a docker container, so the output of cat /proc/version is this: Linux version 5.4.0-1071-aws (buildd@lcy02-amd64-020) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04))
  • Pendulum version: 2.1.2

Issue

In a docker container with no timezone configuration (presumably), from_format errors out when passing in the timezone parameter. For example, this line from the docs: pendulum.from_format('1975-05-21 22', 'YYYY-MM-DD HH', tz='Europe/London') will spit out the error RuntimeError: Unable to find any timezone configuration. This same behavior happens when I try to run something like pendulum.now() with no arguments which makes sense because I'm assuming it's trying to get the local time but can't. In our docker container we strictly do not want anything to use local time when it's not needed which is why there is no timezone configuration and I feel like it's completely unnecessary here. If I pass in the tz parameter it shouldn't need to rely on local time at all. Looking at the source code, I'm pretty sure this is because now() is being used here: https://github.com/sdispater/pendulum/blob/f1df7dc3f838bd4ab1075ba25c8b6ce5d8141995/pendulum/__init__.py#L238. I'd love to use pendulum in our production server given the ease of managing timezones, but this behavior is completely blocking it and rendering it unusable right now.

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