Giter Site home page Giter Site logo

moment-timezone's Introduction

NPM version NPM downloads MIT License Build Status Coverage Status FOSSA Status SemVer compatibility

A JavaScript date library for parsing, validating, manipulating, and formatting dates.

Project Status

Moment.js is a legacy project, now in maintenance mode. In most cases, you should choose a different library.

For more details and recommendations, please see Project Status in the docs.

Thank you.

Resources

License

Moment.js is freely distributable under the terms of the MIT license.

FOSSA Status

moment-timezone's People

Contributors

alaouy avatar askhogan avatar citysim avatar dependabot[bot] avatar ellenaua avatar frost avatar gilmoreorless avatar gitter-badger avatar hndeploys avatar hurrymaplelad avatar icambron avatar ichernev avatar joekrill avatar jonahkirangi avatar kashifshamaz21 avatar keheliya avatar kkirsche avatar lookfirst avatar maggiepint avatar mattjohnsonpint avatar mikefrey avatar mridgway avatar neweracracker avatar praneeth-m avatar raphyluke avatar samuelcole avatar ssskip avatar thatmarvin avatar timrwood avatar zavyrylin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moment-timezone's Issues

format() returns wrong result when timezone is applied

Please take a look at the following code:

moment(1369627200000).format('wo [week] YYYY')
"22nd week 2013"

It looks correct. Applying a different timezone I get a wrong result:

moment(1369627200000).tz('America/New_York').format('wo [week] YYYY')
"27th week 2013"

Does not recognize all Time Zone Id's returned by google maps

Google maps seems to return some time zone ids in a slightly different format than is recognized by your time zone data.

e.g.
Google: America/Cordoba
Moment: America/Argentina/Cordoba

This raises the error:
Uncaught TypeError: Cannot call method 'rule' of undefined

To replicate:
moment().clone().tz('America/Cordoba')

This can be alleviated by adding links between google's returned time zone id's and the ones already provided by your data set.

[v0.0.3] Can't get simple test working

I'm using momentjs 2.3.1 and moment-timezone 0.0.3.
Here is the simple line of code to test it

console.log(moment(1379664031).tz("America/Los_Angeles").format("YYYY-MM-DD HH:mm:ss"));

The error I get:

Uncaught TypeError: Cannot call method 'rule' of undefined

Do I have to add timezone before to use them? is there a way to import all timezone if it's the case?

Construct a moment from date, time and timezone, then format it back with timezone

Two part question:

  • Is it possible to construct a moment from a date, time and timezone? For example how do I construct August 15, 2013, 1:00 PM in timezone = "America/Chicago"? I think [PR #25] addresses this but I can't be sure.

  • How do I fomat such a moment back with a timezone abbreviation, for example "15 Aug 2013 01:00 PM CDT". I tried the following, but it prints the timezone as an offset.

    moment("08/15/2013 1:00 PM -0500", "MM/DD/YYYY hh:mm A Z")
    .tz('America/Chicago')
    .format('DD MMM YYYY hh:mm A Z');

produces

15 Aug 2013 01:00 PM -05:00

Timezone is printed as offset, not as CDT

add support for UTC timezone

moment.tz('UTC') should be a valid synonym for moment.utc()

Right now:

moment().tz('UTC')
TypeError: Cannot call method 'rule' of undefined

fails to run straight from documentation

node --version
v0.10.10
npm install moment-timezone
node

var moment = require('moment-timezone');
undefined
> moment().tz("America/Los_Angeles").format();
TypeError: Cannot call method 'rule' of undefined
    at Object.ZoneSet.zoneAndRule (/Users/taf2/work/phonetrac/services/ctm-reports/node_modules/moment-timezone/moment-timezone.js:308:24)
    at Object.ZoneSet.offset (/Users/taf2/work/phonetrac/services/ctm-reports/node_modules/moment-timezone/moment-timezone.js:322:28)
    at Function.moment.updateOffset (/Users/taf2/work/phonetrac/services/ctm-reports/node_modules/moment-timezone/moment-timezone.js:438:21)
    at Object.moment.fn.tz (/Users/taf2/work/phonetrac/services/ctm-reports/node_modules/moment-timezone/moment-timezone.js:450:13)
    at repl:1:10
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
>

can't be used in karma tests for angular

angular-mocks defines a global 'module' var which line 508 takes to mean the presence of a global require function. We've had to comment that for now, would be nice if this check was a little more thorough.

change default timezone

It would be great to have a method to change the default timezone (eg: when the application starts moment.tz.setDefault('America/New_York')). Then, all the subsequent calls to moment() will automatically set the timezone with the default one.

Is This Usable Yet?

I looked over the files and loosely could see the parsed data files, but could not understand how to use this from an instance of moment.js. Any guidance?

Wrong behavior when creating a moment with timezone

According to the documents:

moment.tz("2013-11-18 11:55", "America/Toronto").format(); // "2013-11-18T11:55:00-05:00"

But running this code in my browser with locale UTC +0100 gives me this

moment.tz("2013-11-18 11:55", "America/Toronto").format();
"2013-11-18T05:55:00-05:00"

seems to me that it first creates a new Moment with my systems locale and then change the timezone which does not provide the expected behavior.

If however I use my own timezone it works as expected and I think that's what the author of the docs did.

Not handling DST properly

I'm creating a utility function from moment timezone that gives me the UTC timestamp of the start of given day. Its used when I select a date on a calendar picker, I want to have the corresponding UTC timestamp in the timezone the user is in. It looks something like:

   getTimestamp(year, month, day, hour, minutes....)
      moment().tz(myTimezone).year(year).month(month).day(day).....valueOf()

This works fine, except on DST in the US/Eastern timezone (March 9), it gives me 23:00:00 on March 8. Is this expected behavior? If it is, what's the proper way to implement this?

Minified moment-timezone.min.js does not work.

Take the following example to force a user's browser to a business' HQ time.

var hqTz        = "America/Chicago",
    rightNow    = moment.tz( hqTz ),
    opens       = moment.tz( hqTz ).hour( 8 ).minute( 30 ).second( 0 ).millisecond( 0 ),
    closes      = moment.tz( hqTz ).hour( 20 ).minute( 0 ).second( 0 ).millisecond( 0 );

console.log( "Local time: " + moment().format() );
console.log( "HQ time: " + rightNow.format() );
console.log( "HQ opens: " + opens.format() );
console.log( "HQ closes: " + closes.format() );

When using the non-minified version, the output is as expected:

Local time: 2013-09-30T07:07:42-10:00
HQ time: 2013-09-30T12:07:42-05:00
HQ opens: 2013-09-30T08:30:00-05:00
HQ closes: 2013-09-30T20:00:00-05:00

However, when using the minified version (the only change made between page loads), the output is incorrect (perhaps as if the timezone data never got loaded):

Local time: 2013-09-30T06:58:27-10:00
HQ time: 2013-09-30T16:58:27+00:00
HQ opens: 2013-09-30T08:30:00+00:00
HQ closes: 2013-09-30T20:00:00+00:00

Adding more links for countries with a single timezone.

I know the related data is gathered from TZDB. But I think it would be convenient to add more links for countries with a single timezone.

There are already some in place. For example:

"Poland": "Europe/Warsaw"
"Portugal": "Europe/Lisbon"
"Iran": "Asia/Tehran"
"Israel": "Asia/Jerusalem"
"Japan": "Asia/Tokyo"

Would there be a possibility to enhance the list of links?

Bonus: Maybe this could be further enhanced with US states with a single timezone. For example:

"Colorado": "America/Denver"
"Illinois": "America/Chicago"

Make data builder

Users should be able to construct the data files based on which zones they need to support.

Get potential timezone name from regular moment or js Date

I realize getting a timezone name from a JS date object is generally impossible. If I recall, that was why the 'z' token was originally removed from moment.js. Even with moment-timezone.js, one gmt offset value could map to a dozen timezone names. But, would it still be possible to add a function (maybe named and applied to moment.zoneNames()) to get a list of possible timezone matches using gmt offset or any other usable properties of the moment or date instance?

This would allow the programmer to set a default date for the client (see issue 15) by selecting the very first match or instead work with an array of possible matches to further work on.

Example use: you're in New York and you visit a page. var m = moment(); would get your current date/time with utc offset -4. Then, use m.zoneNames() to get a list of possible timezone matches. The page could just use the first match, use other methods to narrow down the matches further, or prompt the user to select from this narrowed list their current timezone.

I noticed the 'z' format modifier was restored for moment-timezone.js. Understood that likely it wouldn't work for my suggestion due to issues with mapping to multiple zones.

I'm sorry, I'm not too familiar with the tz database zones and rules to provide a suggested code example or commit.

your stuff does not work

  • include moment, then moment-tz
moment.tz.add({
    "zones": {
        "EST": [
            "-5 - EST"
        ],
        "MST": [
            "-7 - MST"
        ]
    },
    "rules": {},
    "links": {}
});

moment().tz('EST').format() is the same as moment().tz('MST').format()

Inclusion of module.exports in index.js breaks non-Node projects.

Using latest angular-moment as part of a project (which depends on the latest moment-timezone) nukes non-Node releases. In this case, a project using Nginx/uWSGI passing through static content.

I'm guessing this is because module.exports is a Node-only thing, and when it's served by Nginx the object doesn't exist. I don't know how fixable this is, knowing next to nothing about Node - I worked around it by reverting to an older version of angular-moment that doesn't depend on moment-timezone.

TypeError: zone is undefined

I'm getting this error when trying to use Moment.js with timezone, the error is being triggered in the line 308 of the moment-timezone.js file where the piece of code is: "return [zone, zone.rule(mom, lastZone)];" in the zoneAndRule function.

What I'm trying to do is a console.log() of a date with the following code:

console.log(moment().tz("America/Los_Angeles").format());

I'm using require.js with Backbone.js

generate zone files for just a specific city to reduce file size?

Hi is it possible to create zone js files for just a specific city (eg. "Europe/London") to reduce file size since I know I only need this particular time zone?

I see there is a generate-zones.js so I'm guessing it's possible but not quite sure how to go about it? I note @asprouse has also made some changes to this file...

Any help would be appreciated!

Release changes from #39 as 0.0.4

I'm really digging moment-timezone, and the performance enhancement from #39 has made it much faster than any alternatives, but I'd love to be able to use a point release rather than point my project at a specific commit. Would it be possible to merge those changes and release 0.0.4?

Thanks!

Daylight saving and add function

it seems that when hitting daylight saving, a moment object with time zone can not compute add days properly

var day = moment("2012-11-04");
console.log(day);
console.log(day.add("days",1));

//output with firefox+firebug
//Sun Nov 04 2012 00:00:00 GMT-0400 { _i="2012-11-04", _f="YYYY-MM-DD ", _isUTC=false, more...}
//Mon Nov 05 2012 00:00:00 GMT-0500 { _i="2012-11-04", _f="YYYY-MM-DD ", _isUTC=false, more...}


var dayTZ = moment("2012-11-04").tz("America/New_York");
console.log(dayTZ);
console.log(dayTZ.add("days",1));

//Sun Nov 04 2012 00:00:00 GMT-0400 { _i="2012-11-04", _f="YYYY-MM-DD ", _isUTC=true, more...}
// instead Nov 05, it returns +1 hour
//Sun Nov 04 2012 01:00:00 GMT-0400 { _i="2012-11-04", _f="YYYY-MM-DD ", _isUTC=true, more...}
// and continue +24 hours after that
Mon Nov 05 2012 01:00:00 GMT-0500 { _i="2012-11-04", _f="YYYY-MM-DD ", _isUTC=true, more...}

var dayTZ2 = moment("2012-11-01").tz("America/New_York");
console.log(dayTZ2);
console.log(dayTZ2.add("days",1));

//when not crossing daylight saving, timezone works properly
Thu Nov 01 2012 00:00:00 GMT-0400 { _i="2012-11-01", _f="YYYY-MM-DD ", _isUTC=true, more...}
//Fri Nov 02 2012 00:00:00 GMT-0400 { _i="2012-11-01", _f="YYYY-MM-DD ", _isUTC=true, more...}

with timezone-data as:

define(["moment-timezone"], function (moment) {
    moment.tz.add({
        "zones": {
            "America/Los_Angeles": [
                "-7:52:58 - LMT 1883_10_18_12_7_2 -7:52:58",
                "-8 US P%sT 1946 -8",
                "-8 CA P%sT 1967 -8",
                "-8 US P%sT"
            ],
            "America/New_York": [
                "-4:56:2 - LMT 1883_10_18_12_3_58 -4:56:2",
                "-5 US E%sT 1920 -5",
                "-5 NYC E%sT 1942 -5",
                "-5 US E%sT 1946 -5",
                "-5 NYC E%sT 1967 -5",
                "-5 US E%sT"
            ]
        },
        "rules": {
            "US": [
                "1918 1919 2 0 8 2 0 1 D",
                "1918 1919 9 0 8 2 0 0 S",
                "1942 1942 1 9 7 2 0 1 W",
                "1945 1945 7 14 7 23 1 1 P",
                "1945 1945 8 30 7 2 0 0 S",
                "1967 2006 9 0 8 2 0 0 S",
                "1967 1973 3 0 8 2 0 1 D",
                "1974 1974 0 6 7 2 0 1 D",
                "1975 1975 1 23 7 2 0 1 D",
                "1976 1986 3 0 8 2 0 1 D",
                "1987 2006 3 1 0 2 0 1 D",
                "2007 9999 2 8 0 2 0 1 D",
                "2007 9999 10 1 0 2 0 0 S"
            ],
            "CA": [
                "1948 1948 2 14 7 2 0 1 D",
                "1949 1949 0 1 7 2 0 0 S",
                "1950 1966 3 0 8 2 0 1 D",
                "1950 1961 8 0 8 2 0 0 S",
                "1962 1966 9 0 8 2 0 0 S"
            ],
            "NYC": [
                "1920 1920 2 0 8 2 0 1 D",
                "1920 1920 9 0 8 2 0 0 S",
                "1921 1966 3 0 8 2 0 1 D",
                "1921 1954 8 0 8 2 0 0 S",
                "1955 1966 9 0 8 2 0 0 S"
            ]
        },
        "links": {}
    });
});

Incorrect result for constructor with timezone

// Generated by the website
moment.tz.add({
   "zones": {
       "America/Los_Angeles": [
           "-7:52:58 - LMT 1883_10_18_12_7_2 -7:52:58",
           "-8 US P%sT 1946 -8",
           "-8 CA P%sT 1967 -8",
           "-8 US P%sT"
       ]
   },
   "rules": {
       "US": [
           "1918 1919 2 0 8 2 0 1 D",
           "1918 1919 9 0 8 2 0 0 S",
           "1942 1942 1 9 7 2 0 1 W",
           "1945 1945 7 14 7 23 1 1 P",
           "1945 1945 8 30 7 2 0 0 S",
           "1967 2006 9 0 8 2 0 0 S",
           "1967 1973 3 0 8 2 0 1 D",
           "1974 1974 0 6 7 2 0 1 D",
           "1975 1975 1 23 7 2 0 1 D",
           "1976 1986 3 0 8 2 0 1 D",
           "1987 2006 3 1 0 2 0 1 D",
           "2007 9999 2 8 0 2 0 1 D",
           "2007 9999 10 1 0 2 0 0 S"
       ],
       "CA": [
           "1948 1948 2 14 7 2 0 1 D",
           "1949 1949 0 1 7 2 0 0 S",
           "1950 1966 3 0 8 2 0 1 D",
           "1950 1961 8 0 8 2 0 0 S",
           "1962 1966 9 0 8 2 0 0 S"
       ]
   },
   "links": {}
});

console.log(  moment("2013-12-25").format() );
// Logs "2013-12-25T00:00:00-08:00" for me

console.log(  moment("2013-12-25", "America/Los_Angeles").format()  )
// Logs "0000-12-25T00:20:00-08:00" for me

The year disappears and the minutes are set to 20 (from 0) when I attempt this.

Format doesn't use the timezone settings

I am outputting different times depending on timezones, and it works until I apply a format to them, the it output UTC0 time.

What I am testing is:

console.log(timezone);
console.log(moment().tz(timezone).zone());
console.log(moment().tz(timezone).format());
console.log(moment().tz(timezone).format('MMMM Do YYYY, h:mm:ss a'));

and the results are:

Europe/Berlin
-60
2014-02-20T11:09:56+01:00
February 20th 2014, 11:09:56 am

Asia/Chongqing
-480
2014-02-20T11:09:56+08:00
February 20th 2014, 11:09:56 am

Asia/Seoul
-540
2014-02-20T11:09:56+09:00
February 20th 2014, 11:09:56 am

Asia/Singapore
-480
2014-02-20T11:09:56+08:00
February 20th 2014, 11:09:56 am

America/Sao_Paulo
180
2014-02-20T11:09:56-03:00
February 20th 2014, 11:09:56 am

I am using the latest versions of moment, moment-timezone and the complete set of data.

Time Offset of "Asia/Tehran" is wrong

Timezone "Asia/Tehran" is +03:30 which should have time offset +0330
Actually, all timezones with +/-xx:30 have the same issue.
Check

moment().tz("Asia/Tehran").format("ZZ")
"+0350"

The result of two statements below should be the same, but there 20 min different.

var now = moment().tz("Asia/Tehran").format("YYYY-MM-DD HH:mm ZZ")
console.log(now);
"2013-10-28 14:26 +0350"

var another_now = moment(now).tz("Asia/Tehran").format("YYYY-MM-DD HH:mm ZZ")
console.log(another_now);
"2013-10-28 14:06 +0350"

Behavior of Moment Differs from Documentation

The documentation claims this:

moment.tz("2013-11-18 11:55", "America/Toronto").format();
"2013-11-18T11:55:00-05:00"
moment.tz(new Date(2013, 11, 18), "America/Toronto").format();
"2013-12-18T00:00:00-05:00"

Actual behavior:

moment.tz("2013-11-18 11:55", "America/Toronto").format();
"2013-11-18T06:55:00-05:00"
moment.tz(new Date(2013, 11, 18), "America/Toronto").format();
"2013-12-17T19:00:00-05:00"

It would appear the moment object itself is somehow assuming local time?

Zone aliases are missing from data

Aliases such as US/Pacific are missing from the time zone data.

For good interop with other systems, we should have support for aliases.

It could be a global option on the zone builder, so those that want more pristine data and don't have compatibility concerns could omit them.

Failing unit tests.

Just opened http://momentjs.com/timezone/test/ and ran unit tests. Here's results.

102724 tests passed. 758 failed.

Date.prototype.toString = Mon Jul 08 2013 11:28:59 GMT+0300 (FET)
Date.prototype.toLocaleString = 7/8/2013 11:28:59 AM
Date.prototype.getTimezoneOffset = -180
navigator.userAgent = Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36

List of failing tests in JSON format:

["255.2","255.6","256.2","256.6","257.2","257.6","258.2","258.6","277.2","277.6","278.2","278.6","279.2","279.6","280.2","280.6","440.2","440.6","441.2","441.6","442.2","442.8","443.2","443.6","512.2","512.6","513.2","513.6","514.2","514.8","515.2","515.6","1294.2","1294.6","1295.2","1295.6","1296.2","1296.6","1297.2","1297.6","1357.2","1357.6","1358.2","1358.6","1359.2","1359.6","1360.2","1360.6","1593.2","1593.6","1594.2","1594.6","1595.2","1595.6","1596.2","1596.6","1776.2","1776.6","1777.2","1777.6","1778.2","1778.6","1779.2","1779.6","1799.2","1799.6","1800.2","1800.6","1801.2","1801.6","1802.2","1802.6","1907.2","1907.6","1908.2","1908.6","1909.2","1909.6","1910.2","1910.6","1978.2","1978.6","1979.2","1979.6","1980.2","1980.6","1981.2","1981.6","2057.2","2057.6","2058.2","2058.6","2059.2","2059.6","2060.2","2060.6","2178.2","2178.6","2179.2","2179.6","2180.2","2180.6","2181.2","2181.6","2237.2","2237.6","2238.2","2238.6","2239.2","2239.6","2240.2","2240.6","2339.2","2339.6","2340.2","2340.6","2341.2","2341.6","2342.2","2342.6","2399.2","2399.6","2400.2","2400.6","2401.2","2401.6","2402.2","2402.6","2527.2","2527.6","2528.2","2528.6","2529.2","2529.6","2530.2","2530.6","2760.2","2760.6","2761.2","2761.6","2762.2","2762.6","2763.2","2763.6","3116.2","3116.6","3117.2","3117.6","3118.2","3118.6","3119.2","3119.6","3177.2","3177.6","3178.2","3178.6","3179.2","3179.6","3180.2","3180.6","3242.2","3242.6","3243.2","3243.6","3244.2","3244.6","3259.2","3259.6","3260.2","3260.6","3261.2","3261.8","3262.2","3262.6","3349.2","3349.6","3350.2","3350.6","3351.2","3351.6","3352.2","3352.6","3423.2","3423.6","3424.2","3424.6","3425.2","3425.6","3426.2","3426.6","3527.2","3527.6","3528.2","3528.6","3529.2","3529.6","3530.2","3530.6","3753.2","3753.6","3754.2","3754.6","3755.2","3755.6","3756.2","3756.6","3869.2","3869.6","3870.2","3870.6","3871.2","3871.6","4025.2","4025.6","4026.2","4026.6","4027.2","4027.6","4028.2","4028.6","4258.2","4258.6","4259.2","4259.6","4260.2","4260.6","4261.2","4261.6","4334.2","4334.6","4335.2","4335.6","4336.2","4336.6","4337.2","4337.6","4452.2","4452.6","4453.2","4453.6","4454.2","4454.6","4455.2","4455.6","4520.2","4520.6","4521.2","4521.6","4522.2","4522.6","4523.2","4523.6","4592.2","4592.6","4593.2","4593.6","4594.2","4594.8","4595.2","4595.6","4692.2","4692.6","4693.2","4693.6","4694.2","4694.6","4695.2","4695.6","4767.2","4767.6","4768.2","4768.6","4769.2","4769.6","4770.2","4770.6","4842.2","4842.6","4843.2","4843.6","4844.2","4844.6","4845.2","4845.6","4953.2","4953.6","4954.2","4954.6","4955.2","4955.6","4956.2","4956.6","5022.2","5022.6","5097.2","5097.6","5098.2","5098.6","5099.2","5099.6","5100.2","5100.6","5158.2","5158.6","5159.2","5159.6","5160.2","5160.6","5161.2","5161.6","5271.2","5271.6","5272.2","5272.6","5273.2","5273.6","5274.2","5274.6","5369.2","5369.6","5370.2","5370.6","5371.2","5371.6","5372.2","5372.6","5609.2","5609.6","5610.2","5610.6","5611.2","5611.6","5612.2","5612.6","5680.2","5680.6","5681.2","5681.6","5682.2","5682.8","5683.2","5683.6","5799.2","5799.6","5800.2","5800.6","5801.2","5801.6","5802.2","5802.6","5938.2","5938.6","5939.2","5939.6","5940.2","5940.6","5941.2","5941.6","6016.2","6016.6","6017.2","6017.6","6018.2","6018.6","6019.2","6019.6","6133.2","6133.6","6134.2","6134.6","6135.2","6135.6","6136.2","6136.6","6229.2","6229.6","6230.2","6230.6","6231.2","6231.6","6232.2","6232.6","6293.2","6293.6","6294.2","6294.6","6295.2","6295.6","6296.2","6296.6","6386.2","6386.6","6387.2","6387.6","6388.2","6388.6","6389.2","6389.6","6457.2","6457.6","6458.2","6458.6","6459.2","6459.8","6460.2","6460.6","6520.2","6520.6","6521.2","6521.6","6522.2","6522.6","6523.2","6523.6","6613.2","6613.6","6614.2","6614.6","7834.2","7834.6","7835.2","7835.6","7836.2","7836.6","7837.2","7837.6","8507.2","8507.6","8508.2","8508.6","8509.2","8509.6","8510.2","8510.6","8572.2","8572.6","8573.2","8573.6","8574.2","8574.6","8575.2","8575.6","8632.2","8632.6","8633.2","8633.6","8634.2","8634.6","8635.2","8635.6","8694.2","8694.6","8695.2","8695.6","8696.2","8696.6","8697.2","8697.6","8801.2","8801.6","8802.2","8802.6","8803.2","8803.6","8804.2","8804.6","8901.2","8901.6","9030.2","9030.6","9103.2","9103.6","9104.2","9104.6","9201.2","9201.6","9202.2","9202.6","9433.2","9433.6","9501.2","9501.6","9502.2","9502.6","9503.2","9503.6","9504.2","9504.6","9576.2","9576.6","9577.2","9577.6","9578.2","9578.6","9579.2","9579.6","9637.2","9637.6","9638.2","9638.6","9639.2","9639.6","9640.2","9640.6","9712.2","9712.6","9713.2","9713.6","9714.2","9714.6","9715.2","9715.6","9802.2","9802.6","9803.2","9803.6","9804.2","9804.6","9805.2","9805.6","9926.2","9926.6","9927.2","9927.6","9928.2","9928.6","9929.2","9929.6","9988.2","9988.6","9989.2","9989.6","10056.2","10056.6","10057.2","10057.6","10058.2","10058.6","10059.2","10059.6","10148.2","10148.6","10149.2","10149.6","10150.2","10150.6","10151.2","10151.6","10216.2","10216.6","10217.2","10217.6","10218.2","10218.6","10219.2","10219.6","10293.2","10293.6","10294.2","10294.6","10295.2","10295.6","10296.2","10296.6","10432.2","10432.6","10433.2","10433.6","10434.2","10434.6","10435.2","10435.6","10547.2","10547.6","10548.2","10548.6","10549.2","10549.6","10550.2","10550.6","10646.2","10646.6","10647.2","10647.6","10648.2","10648.6","10704.2","10704.6","10705.2","10705.6","10706.2","10706.6","10707.2","10707.6","10791.2","10791.6","10792.2","10792.6","10998.2","10998.6","10999.2","10999.6","11000.2","11000.6","11001.2","11001.6","11118.2","11118.6","11119.2","11119.6","11120.2","11120.6","11121.2","11121.6","11210.2","11210.6","11211.2","11211.6","11212.2","11212.6","11213.2","11213.6","11292.2","11292.6","11293.2","11293.6","11294.2","11294.6","11295.2","11295.6","11377.2","11377.6","11378.2","11378.6","11379.2","11379.6","11380.2","11380.6","11506.2","11506.6","11507.2","11507.6","11508.2","11508.6","11509.2","11509.6","11615.2","11615.6","11616.2","11616.6","11617.2","11617.6","11618.2","11618.6","11707.2","11707.6","11708.2","11708.6","11709.2","11709.6","11710.2","11710.6","11778.2","11778.6","11779.2","11779.6","11780.2","11780.6","11781.2","11781.6","11927.2","11927.6","11928.2","11928.6","11929.2","11929.6","11930.2","11930.6","12086.2","12086.6","12087.2","12087.6","12088.2","12088.6","12089.2","12089.6","12145.2","12145.6","12146.2","12146.6","12147.2","12147.6","12148.2","12148.6","12395.2","12395.6","12396.2","12396.6","12397.2","12397.6","12398.2","12398.6","12465.2","12465.6","12466.2","12466.6","12467.2","12467.6","12468.2","12468.6","12646.2","12646.6","12647.2","12647.6","12648.2","12648.6","12649.2","12649.6","12767.2","12767.6","12768.2","12768.6","12769.2","12769.6","12770.2","12770.6","12853.2","12853.6","12854.2","12854.6","12855.2","12855.6","12856.2","12856.6","12928.2","12928.6","12929.2","12929.6","12930.2","12930.6","12931.2","12931.6","13358.2","13358.6","13359.2","13359.6","13360.2","13360.6","13361.2","13361.6","13419.2","13419.6","13420.2","13420.6","13421.2","13421.6","13422.2","13422.6"]

Wrong Timezone

time = 1372175640 * 1000
moment(time).tz('America/Chicago').format("YYYY-MM-DD hh:mm A")
"2013-06-25 10:54 AM"
new Date(time).toString()
"Tue Jun 25 2013 10:54:00 GMT-0500 (CDT)"

Chicago is GMT -6, notice the hour is not accurate... This does not seem to be accurate.

Wrong date manipulation when date passes through tz offset change

When using 'add' or 'subtract' (or maybe other) moment.js functions, result is wrong if date passes through tz offset change.

Example:

var mom = moment('2012-10-28 00:00:00 +01:00').tz('Europe/London');
alert(mom.format());

mom.add('days', 1);
alert(mom.format());

Result:

2012-10-28T00:00:00+01:00
2012-10-28T01:00:00+01:00

Expected result:

2012-10-28T00:00:00+01:00
2012-10-29T00:00:00+00:00

Jsfiddle: http://jsfiddle.net/27ytF/1/

Same bug with other units.

I don't see a way to get an easy list of the available timezones

My use case is populating a select element with options for the available timezones so the user can set their timezone. I was hoping for something along the lines of

moment.tz.getTimezones()
which would return something like

[
    {
        name: "Eastern Standard Time"
      , locale: "America/New_York"
      , abbreviation: "EST"
      , offset: "-5"
    }
  , {
        name: "Central Standard Time"
      , abbreviation: "CST"
      , locale: "America/Chicago"
      , offset: "-6"
    }
]

calendar() ignores tz value when calculating today/tomorrow/etc.

As I write this, 1379227209982 is yesterday at 11:40 p.m. in 'America/Los_Angeles', today at 7:40 a.m. in London.

On a computer running in London,

 > moment(1379227209982).tz('America/Los_Angeles').calendar()
'Today at 11:40 PM'

which seems wrong to me.

On a computer running in the 'America/Los_Angeles' timezone, i get the expected result
'Yesterday at 11:40 PM'

Is this a bug or am I using it incorrectly?

construct moment in zone

This creates the moment in local time:

moment("2013-01-01T00:00:00")

This creates the moment in UTC:

moment.utc("2013-01-01T00:00:00")

So I would expect to be able to create a moment in a particular zone with:

moment.tz("America/New_York","2013-01-01T00:00:00")

That gives an error, so I tried this:

moment.tz("2013-01-01T00:00:00", "America/New_York")

And it works, but gives a result of 2013-01-01T02:00:00-05:00. I would expect 2013-01-01T00:00:00-05:00.

I think it is assuming the input value is in my local offset (-07:00) and then converting it to the time zone specified.

All together, I'd expect to be able to convert from time zone A to time zone B like this:

moment.tz("2013-01-01T00:00:00","America/New_York").tz("America/Los_Angeles").format()

Also - we need a way to deal with ambiguous or invalid input times.

Exclude historic information from moment timezone data

Hey guys,

It would be really great to have a GUI to create a subset of the moment timezone data that only supports future time conversions going forward from a specific date.

My use case is that I'll be using moment timezone for scheduling purposes (things happening in the future) and will not need to convert offsets for dates previous to the date that I release my the feature. Obviously I can go in and manually remove data but it would be nice to be able to do it via the timezone data GUI.

Great plugin! Thanks for all the hard work.

Local Time format with seconds

It would be helpful to have a localized time format similar to "LT" that includes seconds in the format. Currently "LT" it's only hh:mm and possibly AM/PM if your regional settings call for it. Perhaps "LTT"...

Timezones matching the current system timezone

Hello,

I need to know which timezones match the current system timezone, in order to do some date format manipulation on server side.
Few apis exists for this feature, and it is not a simple because in javascript we need to deal with timezone offset and test multiple dates.

However this thread on stackoverflow talks about this feature using moment timezone datas : http://stackoverflow.com/questions/19420582/detect-the-id-of-the-current-user-timezone-using-moment-js

I could simply used this peace of code but it can be certainly improve and why not include in moment timezone library.

The person that post this peace of code test the current date, the dates 4 and 8 months later and the same three dates five years before.
Is it a good strategy ? Can I improve it to have closer timezones matching ?

I need this feature so I can improve this peace of code with your advices and, if you're agreed, publish it in your repository.

.fromNow() does not respect timezone information

moment('2013-10-08T20:42:52.0845758').fromNow();
"7 minutes ago"
moment('2013-10-08T20:42:52.0845758').tz("America/New_York").fromNow();
"7 minutes ago"
moment('2013-10-08T20:42:52.0845758').tz("America/Los_Angeles").fromNow();
"7 minutes ago"

Is this a bug or i'm doing something wrong? not sure how to get this working with the timezone.

moment-timezone performance issues

Hello,

Thanks for this library it really rocks. One issue I have with it though is performance. When using only moment and manipuilating dates, it is very fast. When adding timezone support it becomes much slower:

var m = moment(new Date());
m.add('days', 1);
// Takes ~0.2ms

m = moment(new Date()).tz("America/Los_Angeles");
m.add('days', 1);
// Takes ~20ms

Is it something you can and are planning to solve, or is it due to having to do a lot of stuff on top of the native Date object and there is not much you can do about it?

Daylight Savings

Are there plans to support daylight savings?
Perhaps that is beyond the scope of this project, but at least for me, it would need to have support for daylight savings to be something I could use.
Consider:
Saving an event to a database (as UTC) and the server must know when to notify the user of the event when it occurs. Without accounting for daylight savings, it will be an hour early six months of the year (at least in the northern hemisphere).

Issue With Setters Near The Start Of A Month

I am experiencing this issue using startOf. Attempting to go to the start of a year, when the moment is currently in the first hour of a month actually changes the date to the first of December.

For example:

moment().tz('Europe/Paris').startOf('M').startOf('y')
moment().tz('Europe/Paris').startOf('M').add('h', 1).subtract('ms', 1).startOf('y')
moment(1377986400000).tz('Europe/Paris').startOf('y')

This, weirdly, does not occur in some Easternly timezones. In my experience it occurred for Asia/Damascus, but not Asia/Qatar.

Through testing, I have found that:

moment().tz('Europe/Paris').startOf('M').months(0).date(1)

Will produce the first of December. As such, a quick fix to the code (which avoids, but may not fix) the underlying issue is to swap this to:

moment().tz('Europe/Paris').startOf('M').date(1).months(0)

Amending the startOf method to avoid the switch fall-through technique and instead specifying, for each case, what should actually happen in this order does work as a quick patch, although it appeared to break other parts of my program.

List of timezones

I'm looking for a way to output all added timezones, preferably ordered correctly. I didn't see any possible way right now.

Before I fork and patch, I wanted to ask if there was some way that maybe I looked past.

Zone Data Builder

The online zone data builder is pretty cool. But it needs a few things:

  • Something at the top of the builder, and in the generated data file, that show the version of the TZDB that was used to generated the data, (i.e., "2013d")
  • An easy way to select all zones - or a quick link to download the file containing all zones. (limiting the data may help for browser scenarios, but node.js apps will probably want the whole thing)
  • A link to download the generated output as a .js or .json file. Perhaps with an option to minify.
  • Instructions for running the builder yourself offline. Often people will want to build the file directly from the IANA/Olson sources. Sometimes there are fixes in eggert/tz that aren't yet in a release and people need to get them out to customers in a hurry.

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.