Comments (11)
Hi,
I have the same issue and I cannot find why it doesn't work. When the code is not built with r.js, it works like a charm, but when the code gets minified, it is not possible to change timezone (i.e. it stays in the Greenwhich timezone).
Have you found a solution to this issue?
from moment-timezone.
I just negate the time zone delta – I need GMT+1, so I use moment().zone(-1) and it gets me right time zone.
From: nanopils [mailto:[email protected]]
Sent: Wednesday, January 29, 2014 4:45 PM
To: moment/moment-timezone
Subject: Re: [moment-timezone] Minified moment-timezone.min.js does not work. (#37)
Hi,
I have the same issue and I cannot find why it doesn't work. When the code is not built with r.js, it works like a charm, but when the code gets minified, it is not possible to change timezone (i.e. it stays in the Greenwhich timezone).
Have you found a solution to this issue?
—
Reply to this email directly or view it on GitHub #37 (comment) . https://github.com/notifications/beacon/919599__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNjUxNzkyMSwiZGF0YSI6eyJpZCI6MTc2MDM0OTh9fQ==--1fe0221c12b3a7e3f43d350f068c9d5b5cdf76f8.gif
from moment-timezone.
@korondy: thanks, but this does not take in consideration the change of summer/winter time which can occur at different times depending on location. I was considering changing the timezone using the zone method, but there are too much factors involved to get it right with this method.
What I would like is to fix the moment-timezone.min bug when minified with require.js. It might be something to add in the require.config file that I'm not aware of?
from moment-timezone.
@rockerest: did you find a solution to this issue or did you fix it in another way?
from moment-timezone.
I have not discovered a workable solution using the minified version.
To be fair, I spent very little time trying to fix it once I discovered what the issue was. I had already wasted a lot of time up to that point as I had been operating under the assumption that the minified and non-minified versions were functioning identically.
In Moment's defense, I have had similar issues with other libraries' minified versions. It appears that JS minification can be a little finicky.
My solution has simply been to use the "pretty" (unminified) versions of libraries that have stopped working when I minified them. Not ideal, but it's better than trying to debug third-party code when I have better things to do.
from moment-timezone.
@rockerest and @korondy: thank you for your feedback!
I use require.js to build moment, moment-timezone and moment-timezone-data, but something got ugly with the uglify2 task and broke the moment-timezone AMD module.
In order to fix this, I have used the already-minified version of moment-timezone (instead of the source code), and it now works a treat!
You can find the minified code I used here: https://raw.github.com/moment/moment-timezone/develop/min/moment-timezone.min.js
from moment-timezone.
I believe I've found the problem. I had the same issue as described above. I found that the data script you can download on the moment-timezone homepage is the timezone library WITH the data. It used to be that you had to use both scripts, but now you just use one of those listed on the homepage (the first one is pointless since without data, timezone won't work).
If you include both the timezone script and the data script it will break as indicated in this thread because moment.tz is defined twice. If you only include the data script, everything works.
This isn't very clear in the docs and should be updated. The standalone timezone script should be removed from the homepage as well since it is pointless for anyone to use by itself. The data-builder, when it comes, will probably include the timezone script anyway, and if it doesn't the download for timezone without data can be included on that page instead of the homepage.
from moment-timezone.
@jacwright can you please provide a quick sample of your solution. I want to make sure I including the correct dependencies.
from moment-timezone.
Just be sure to not load the timezone script twice. For example, when you go to download the script on the timezone home page
only download ONE of the three links (really, one of the latter two, the first one by itself is worthless). DO NOT download the first one and try to use it with the 2nd or 3rd.
<!DOCTYPE html>
<html>
<head>
<title>Amazing App with Timezone Support</title>
<script type="text/javascript" src="http://momentjs.com/downloads/moment-with-langs.min.js"></script>
<!--
DO NOT USE THIS. It is included with the following script and
by adding it you define timezone twice and end up with subtle
bugs that you aren't able to explain, such as the ones listed in
this thread.
<script type="text/javascript" src="http://momentjs.com/downloads/moment-timezone.js"></script>
-->
<script type="text/javascript" src="http://momentjs.com/downloads/moment-timezone-with-data.js"></script>
</head>
<body>
<h1>Amazing App with Timezone Support</h1>
</body>
</html>
Hope that helps.
from moment-timezone.
Yeah, I think we should get rid of the first link and have the zone builder spit out the library with embedded data.
from moment-timezone.
I got the same issue and I followed what you said @jacwright, I never even assumed these files could work together so I kept the second version only. If I just try to use the normal moment
everyone works fine, and I'll stick to that until I in fact need the timezone feature.
from moment-timezone.
Related Issues (20)
- The DST calculation does not take effect. HOT 3
- import moment from 'moment-timezone'; import 'moment/min/locales'; not working HOT 5
- Can not set default timezone HOT 2
- Wrong timezone conversion
- error TS2350: Only a void function can be called with the 'new' keyword. new moment(); HOT 3
- 2023d is out HOT 2
- Some tz.guess() tests are failing in 2024 HOT 1
- Canada/Yukon offset before 1967 May 27 is wrong HOT 1
- How does moment.tz(unixTimestamp,timezone) and moment.tz.guess() work? HOT 1
- How can I use moment-timezone with 10 year data range with Typescript types HOT 1
- Moment Timezone has no data for Europe/Ljubljana
- Kazakhstan will switch to a single time zone, UTC+05:00, on March 1, 2024. HOT 1
- 2024a released HOT 1
- Test failure due to rounding error HOT 2
- Timezone Error in v0.5.45 HOT 1
- Wrong Kazakhstan Timezone in 0.5.45 HOT 1
- Incorrect Timezone Offset for 'Asia/Almaty' HOT 1
- The moment-timezone get the time zone of Kazakhstan Asia/Almaty in January 2024 to the DST. HOT 3
- Is there an alternative to moment-timezone with bundled IANA TZ DB? HOT 1
- Getting spilt issue while using moment and moment-timezones HOT 1
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-timezone.