Skip to content

Timezones support is deficient #683

Closed

Description

@noviluni

I think we should rethink how the timezones are applied, as we have more than one case of abbreviations with different meanings.

I could found at least these cases:

I'm not sure about the solution we could implement, but it's obvious that we can not choose a timezone randomly.

Some ideas:

  • We could choose the most used, for example, we could maybe change IST from "Israel Standard Time" (current) to "Indian Standard Time" (hard to decide, not a solution itself).
  • We could add a warning when parsing timezones with more than one meaning (self-explanatory, but not a solution and it could be a problem when people already know it, as it could spam with a lot of warning messages).
  • We could add a setting like "PREFER_TIMEZONE_FROM" or something similar where users can specify if they prefer timezones from a continent or another negative vs positive timezones (I'm not sure about this, as there are some examples in the list (like CDT or ECT) where all the timezones are from the same continent/region).
  • We could add a setting that would allow specifying preferent manual timezones (example: TIMEZONES_EQUIVALENT = {'IST': '+5.30'}). (possible solution but a hard to discover behavior).
  • We could implement some of the above ideas together.

On the other side, we should think about how we could implement more timezones formats like 'Australia/Sydney': #298

Please, if you have any idea add a comment here below 👇 Any idea will be welcomed!!!

Activity

  1. Baviaan commented on May 17, 2020

    @Baviaan
    Contributor

    Thanks for opening this discussion.

    You could interpret it based on the language. For the CST example you could interpret based on whether 'en', 'es' or 'zh' has been set?
    Or perhaps specifically on the locale settings. E.g. CST is Cuba only if 'es-cu' and BST is British only if 'en-gb' has been set?

    That doesn't solve anything if e.g. the locale is set to 'fr-fr', i.e. what should it default to? But that is also the status quo. I like your suggestion to be able to override the default behaviour with a setting: {'IST': '+5.30'}

  2. noviluni commented on May 17, 2020

    @noviluni
    ContributorAuthor

    I hadn't thought about considering the locale to give a better timezone, and I think it could be a really good idea!

    I have to think more about this and how this would affect the current implementation, but it sounds good. Of course, in most cases, this wouldn't help, but in others, it could be really useful. 💪

    @Gallaecio any thought on this? 🙂

  3. Gallaecio commented on May 18, 2020

    @Gallaecio
    Contributor

    I like the ideas. What about combining some of them like this?

    • Switch to new default values based on popularity. Measuring popularity can be hard, though. If in doubt, we can keep whatever the current default is.
    • Log a warning when choosing a global default for an ambiguous timezone. The warning can be silenced by providing disambiguation parameters.
    • Set locale-specific default values for those locales where the choice is unambiguous. These override the global default value when the locale is in the user-defined list of input locales. If the locale list leaves room for ambiguity (e.g. ['en-ie', 'en-in']), use that of the first locale from the list but log a warning.
    • Allow users to define a custom mapping, which would override the locale-specific or global default.
  4. added this to the v1.0.0 milestone on Jun 23, 2020
  5. modified the milestones: v1.0.0, 1.1.0 on Sep 21, 2020
  6. MaximeLaurenty commented on Jul 13, 2021

    @MaximeLaurenty

    Hello,
    Thanks for your work on dateparser!
    Any update on this?
    I just (painfully) discovered IST was set to israeli time rather than indian time.
    I like the idea to be able to provide a mapper to the settings. This is by the way possible with dateutil.parser.parse

    Until a solution is found and implemented though, I think IST should refer to indian time rather than israeli one based on population (which is a proxy for popularity), don't you think?
    (I am neither indian nor israeli, this is not chauvinism)

  7. feigenblatt commented on Feb 11, 2025

    @feigenblatt

    Any updates on this?
    I like the layered approach but it's hard to make sure any automatic detection will work in every possible scenario.
    That means whatever solution is agreed upon that should still include custom mapping as a fallback.
    And if you agree with that, could that be implemented first while the other aspects are worked on?
    In my specific use case that's the only suggestion that would work and should get most people a working solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions