arrow-py / arrow-py/arrow

improved parsing of timezone abbreviations

Open
#1,065 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
9.1k
Forks
784
PR merge metrics
No merged PRs in 30d

Description

## 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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the IANA time-zone database, especially to2050.tzs, and compare its abbreviation data with Arrow 1.2.1's current parsing behavior. Reproduce parsing for the listed abbreviations in Python and define which mappings should be supported; done means the requested abbreviations parse consistently and the documentation reflects the supported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.