GithubHelp home page GithubHelp logo

Comments (4)

timrwood avatar timrwood commented on May 6, 2024

Yeah, I think the only way to test the issue is to replicate the code for getting the timezone. And that doesn't seem like a good test at all.

Maybe I could store a hash of timezones and match the getTimezoneOffset to them. Something like the following link?

http://blog.redfin.com/devblog/2007/08/getting_the_time_zone_from_a_web_browser.html

from moment.

timrwood avatar timrwood commented on May 6, 2024

Hmm, after looking into the timezone information here http://www.iana.org/time-zones, it looks like this may be a sub-optimal solution, as the number of lines in the files for 2011 timezone information is over 15000 lines.

The North America file is over 3k lines itself.

Although, as it is for unit tests, the hash of timezones may be the best solution, as it's not that critical to the codebase.

from moment.

jgwhite avatar jgwhite commented on May 6, 2024

Maybe a naive regex would be enough for this unit test? Something like:

var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz becomes timezone code');

Adjusted appropriately for different locales, this might be enough to verify that something in the ballpark of a timezone code is being returned.

What do you think?

from moment.

jgwhite avatar jgwhite commented on May 6, 2024

I’ve submitted a pull request on this one with my adaptations to the tests.

from moment.

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.