Giter Site home page Giter Site logo

Comments (11)

nanopils avatar nanopils commented on May 23, 2024

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.

korondy avatar korondy commented on May 23, 2024

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.

nanopils avatar nanopils commented on May 23, 2024

@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.

nanopils avatar nanopils commented on May 23, 2024

@rockerest: did you find a solution to this issue or did you fix it in another way?

from moment-timezone.

rockerest avatar rockerest commented on May 23, 2024

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.

nanopils avatar nanopils commented on May 23, 2024

@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.

jacwright avatar jacwright commented on May 23, 2024

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.

gsvitak avatar gsvitak commented on May 23, 2024

@jacwright can you please provide a quick sample of your solution. I want to make sure I including the correct dependencies.

from moment-timezone.

jacwright avatar jacwright commented on May 23, 2024

Just be sure to not load the timezone script twice. For example, when you go to download the script on the timezone home page

screen shot 2014-07-03 at 8 51 29 am

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.

timrwood avatar timrwood commented on May 23, 2024

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.

bitoiu avatar bitoiu commented on May 23, 2024

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)

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.