Comments (4)
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.
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.
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.
I’ve submitted a pull request on this one with my adaptations to the tests.
from moment.
Related Issues (20)
- formatting time in HH:mm shorts 1 hour HOT 4
- Is this project following sem versioning ?
- French (Canada) date format includes an 'e' after the number HOT 2
- Egypt has changed their daylight savings rules again, on short notice HOT 1
- 2 tests failed. diff:diff across DST (3329.17) diff:diff across DST (3329.19)
- monthsShort and format() is returning different values for month names HOT 4
- Is Diff calculation wrong every other month?
- subtract get last week is wrong HOT 3
- America/Mexico_City / DST HOT 1
- moment is not returning correct unix string.
- Getting Syntax Error when change iOS Device Language to Japanese
- moment.min / moment.max doesn't check the first argument to be valid (isValid())
- Date Undefined Get True - moment(undefined).isValid() HOT 1
- Vulnerable dependencies (indirect security issues)
- Wrong Date formatting HOT 1
- Error in the English output of the fromNow() method HOT 3
- .diff() returning NaN sometimes when format is "MMMM YYYY" HOT 2
- Typo Mistake in gu.js (in Gujarati Language) HOT 1
- Which one is the official CDN link? HOT 2
- Czech republic localization HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moment.