Skip to content

improved parsing of timezone abbreviations #1065

@rtphokie

Description

@rtphokie

Issue Description

The documentation suggests agains using abbreviated timezone strings (e.g. EST, UTC, etc.):

timezone names from tz database provided via dateutil package, note that abbreviations such as MST, PDT, BRST are unlikely to parse due to ambiguity. Use the full IANA zone name instead (Asia/Shanghai, Europe/London, America/Chicago etc)

Arrow can successfully parse each of the standard and daylight timezone abbreviations in the United States (except Alaska) and eastern & western Europe (including GMT and UTC): ['CET', 'EDT', 'EET', 'EST', 'GMT', 'HST', 'MET', 'MST', 'UTC', 'WET']

Arrow can and should do better. It exists to improve on datetime and dateutil, why improve on parsing as well?

Timezone abbreviations are not as ambiguous as the documentation claims. It is well defined in the IANA timezone database. Specifically in to2050.tzs (see the IANA timezone database downloadable from the reference link below) which could easily be used to create a mapping from abbreviations to offset.

Additional timezone abbreviations that could be supported (including some historical ones such as war and peace time used in the US during 1942) are:

ACDT, ACST, ADDT, ADT, AEDT, AEST, AHDT, AHST, AKDT, AKST, AMT, APT, AST, AWDT, AWST, AWT, BDST, BDT, BMT, BST, CAST, CAT, CDDT, CDT, CEMT, CEST, CMT, CPT, CST, CWT, ChST, DMT, EAT, EDDT, EEST, EMT, EPT, EWT, FFMT, FMT, GDT, GST, HDT, HKST, HKT, HKWT, HMT, HPT, HWT, IDDT, IDT, IMT, IST, JDT, JMT, JST, KDT, KMT, KST, LMT, LST, MDDT, MDST, MDT, MEST, MMT, MPT, MSD, MSK, MWT, NDDT, NDT, NPT, NST, NWT, NZDT, NZMT, NZST, PDDT, PDT, PKST, PKT, PLMT, PMMT, PMT, PPMT, PPT, PST, PWT, QMT, RMT, SAST, SDMT, SET, SJMT, SMT, SST, TBMT, TMT, WAST, WAT, WEMT, WEST, WIB, WIT, WITA, WMT, YDDT, YDT, YPT, YST, YWT

Reference: https://www.iana.org/time-zones

System Info

  • 🖥 OS name and version: MacOS 11.6.1
  • 🐍 Python version: Python 3.9.1
  • 🏹 Arrow version: 1.2.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions