Giter Site home page Giter Site logo

Comments (5)

mattjohnsonpint avatar mattjohnsonpint commented on May 24, 2024

This isn't a bug in moment-timezone. It's a hole in the tz database.

# Rule  NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
Rule    Japan   1948    only    -       May     Sun>=1  2:00    1:00    D
Rule    Japan   1948    1951    -       Sep     Sat>=8  2:00    0       S
Rule    Japan   1949    only    -       Apr     Sun>=1  2:00    1:00    D
Rule    Japan   1950    1951    -       May     Sun>=1  2:00    1:00    D

# Zone  NAME            GMTOFF  RULES   FORMAT  [UNTIL]
Zone    Asia/Tokyo      9:18:59 -       LMT     1887 Dec 31 15:00u
                        9:00    -       JST     1896
                        9:00    -       CJT     1938
                        9:00    Japan   J%sT

Asia/Tokyo is defined as anything after 1938 follows the Japan rule, but that rule is only defined from the first Sunday following May 1st 1948 (which happens to be May 2nd) forward.

from moment-timezone.

mattjohnsonpint avatar mattjohnsonpint commented on May 24, 2024

Actually, I take back my last comment. I was misinterpreting the data. there is indeed a bug here.

Asia/Tokyo should follow the Japan rule should be followed for anything after 1938. From there forward it should be fixed to UTC+09:00 - except for those ranges defined in the rule, where it should follow the DST logic for those particular ranges.

Since 1948-05-01T16:59:59+00:00 is not in any range in the Japan rule, it doesn't follow DST, but it is still UTC+09:00 and should be considered "standard time".

Question - how can we assume that "S" is the correct letter to replace here?

from moment-timezone.

mattjohnsonpint avatar mattjohnsonpint commented on May 24, 2024

Ok, I found a lot of good information here: How to read the tz database

In particular:

One wrinkle, not fully explained in zic.8.txt, is what happens when switching to a named rule. To what values should the SAVE and LETTER data be initialized?

  • If at least one transition has happened, use the SAVE and LETTER data from the most recent.
  • If switching to a named rule before any transition has happened, assume standard time (SAVE zero), and use the LETTER data from the earliest transition with a SAVE of zero.

We don't appear to be doing that. The replace is done in Zone.prototype.format:

format : function (rule) {
    return this.letters.replace("%s", rule.letters);
}

The problem is that in this case, the rule is empty. The format function needs to be expanded to consider the logic above.

from moment-timezone.

timrwood avatar timrwood commented on May 24, 2024

This issue kind of disappears when switching to the new data format.

from moment-timezone.

mattjohnsonpint avatar mattjohnsonpint commented on May 24, 2024

Very nice. Thanks Tim!

from moment-timezone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.