Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    jbgithub
    @jbgithub

    Hello, I'm just looking to contribute. Here is a regular expression to parse the timezone from a date/time string. It works with the new and old format strings.

    "date.toString() or date.toTimeString()".replace(/^.* (\([A-Za-z ]+\)|[A-Z]{3}).*$/, '$1').replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, '$1$2$3');

    Credit goes to "Mootools More" Date module but I had to modify the first RE since it didn't work with the new string format.

    Mario Contreras
    @marioacc
    Hey guys, I do not know where to ask. But I have a doubt, when I am creating a moment date using moment() and moment.tz() with my actual zone the dates differs by 6 hours, is this behaviour normal?
    suneel bandhu
    @bandhu_suneel_twitter

    Hi I am trying to print the following output but unable to do so,can anyone help to point out where I am wrong?
    Expecting Output = "Atlantic Standard Time"

    Logic:
    var now = new Date();
    var month=now.getMonth();
    var year = now.getFullYear();
    var timeZoneName=moment.tz([year,month],timeZone).format('zz');

    Actual Output: "AST"

    Matt Johnson
    @mj1856
    @bandhu_suneel_twitter - Moment-timezone doesn't have that sort of string.
    prithvipatil
    @prithvipatil
    I have added dependency in bower.json "moment-timezone" : "0.5.14". Is there any way I can load moment-timezone-with-data.js instead of moment-timezone-with-data-2012-2022.js?
    doughock
    @doughock
    I have a UTC time in milliseconds from epoch. I would like to use moment-timezone to return a timezone specific seconds since epoch representation. I see examples using .format to return, but I am overlooking the call to return seconds since epoch.
    Bharat Soni
    @iiison

    Hi, I am using timezone to convert the date into different time zone, this is how I am doing it:

    moment(date).tz('timezone').format(...)

    I am getting error: moment().tz is not a function. I am importing moment using es6 modules, do I need import time zone too? If yes, how do I do that..

    doughock
    @doughock
    @iiison you probably need
     const moment = require('moment-timezone');
    Manish Chandra
    @chandrajob365
    Hello all
    I am using moment-timezone for my company
    new Date() = Thu Jan 18 2018 12:26:00 GMT+0530 (IST) --> current time 
     moment.tz(this.props.driver.timezone) ->  Moment {_isAMomentObject: true, _isUTC: true, _pf: {…}, _locale: Locale, _d: Thu Jan 18 2018 06:27:03 GMT+0530 (IST), …} 
    timeZone = "America/Chicago"
    Its happening in a weird way , moment.tz first converts time into "America/Chicago" timezone and then adds 5:30 min according to IST
    Manish Chandra
    @chandrajob365
    But if I use moment.tz(this.props.driver.timezone).format('MMMM Do YYYY, h:mm:ss a'). It gives correct result January 18th 2018, 12:53:32 am (this is few minutes older as compared to output of new Date())
    Hua Lu
    @hualu00
    Hello all, how can i tell some date is valid or not under certain locale with momentjs?
    Jon New
    @newtang
    This might be the better room for my question. Is there a way to detect if a given timezone is valid with moment? I see it logs an error when it doesn't recognize, but is there anything I can use programmatically?
    Matt Johnson
    @mj1856
    @chandrajob365 - See http://momentjs.com/guides/#/lib-concepts/internal-properties/ (Basically, you should not consume any property prefixed with an underscore).
    Bernhard Grünewaldt
    @clouless
    @mj1856 I was trying to add tz 2018c but now 300 tests fail => clouless/moment-timezone@fbe7ae4
    Should I correct the tests? Most tests seem to "guess" random stuff which does not seem to be deterministic. I read everything in contributing.md about data and all worked. Except now a lot of tests fail. On the develop branch 6 Tests fail anyway.
    Matt Johnson
    @mj1856
    @clouless - Step 8 in the contributing doc describes how tests are rebuilt with grunt data-tests. Yes - there's a degree of randomness to it at present.
    There's also more than just building the data and tests to prep a release, so I can take care of all of it if you like. Though thanks for reminding me.
    If you weren't aware, 2018a and 2018b were recalled, so first true release of this year is 2018c. The main change being for Sao Tome.
    Bernhard Grünewaldt
    @clouless
    @mj1856 ok that would be great :) thanks a lot for your effort!
    Kemal Ahmed
    @goatandsheep

    I'm using moment timezone in typescript using bower and really struggling to import it. I used

    import { moment } from '../../../bower_components/moment/min/moment-with-locales.min.js';
    import {moment as momentTimezone} from '../../../bower_components/moment-timezone/builds/moment-timezone-with-data.min.js';

    this gives Uncaught TypeError: moment.tz is not a function

    and sometimes I was getting Uncaught TypeError: (c || "").toLowerCase is not a function but I don't remember what I did to make it do that.

    Kemal Ahmed
    @goatandsheep
    Ok I figured it out. My issue was a javascript issue and this format actually works fine. I was setting the initial value of a property of a web component to return (() => moment.tz.guess()). Changed it to return moment.tz.guess()

    I'm using moment timezone in typescript using bower and really struggling to import it. I used

    import { moment } from '../../../bower_components/moment/min/moment-with-locales.min.js';
    import {moment as momentTimezone} from '../../../bower_components/moment-timezone/builds/moment-timezone-with-data.min.js';

    this gives Uncaught TypeError: moment.tz is not a function

    and sometimes I was getting Uncaught TypeError: (c || "").toLowerCase is not a function but I don't remember what I did to make it do that.Actually my second line of code was:

    import { moment as moment.tz } from '../../../bower_components/moment-timezone/builds/moment-timezone-with-data.min.js';
    Vartan
    @vartana
    Hi I have this 2/14/2018 5:00 AM and it is timezone -07:00
    the computer is on time zone +04:00
    when I use moment with (2/14/2018 5:00 AM) instead of it seeing it as -07:00 it converts to +04
    how can I tell moment my datetime is 2/14/2018 5:00 AM and it is timezone -07:00
    Manish Chandra
    @chandrajob365
    Hi All
    Manish Chandra
    @chandrajob365
    I am using moment-timezone ver: 0.5.14 and @types/moment-timezone ver: 0.5.4 and json-loader ver: 0.5.7
    Using webpack as build tool
    Server side I am able to use moment-timezone
    but on client side its giving error Uncaught TypeError: Cannot read property 'length' of undefined at addZone (moment-timezone.js:385) at Function.loadData [as load] (moment-timezone.js:456) at Object.hasOwnProperty (index.js:2) at __webpack_require__ (bootstrap 93e619d9be8d81d31053:19) at Object.module.exports (client.bundle.js:10625) at __webpack_require__ (bootstrap 93e619d9be8d81d31053:19) at Object.<anonymous> (driver-header-container.tsx:9) at __webpack_require__ (bootstrap 93e619d9be8d81d31053:19) at Object.<anonymous> (fetch.js:461) at __webpack_require__ (bootstrap 93e619d9be8d81d31053:19)
    Basically with above moment -timezone is not able to read ./data/packed/latest.json
    My web pack config
    Client ---
    ```module: {
    rules: [
    {
    test: /.[t,j]sx?$/,
    exclude: [
    /node_modules/
    ],
    use: [
    {
    loader: 'babel-loader',
    options: {
    presets: ['es2015', 'stage-1'],
    plugins: ['transform-decorators-legacy']
    }
    },
    {
    loader: 'ts-loader',
    options: {
    configFileName: './src/common/ts/amd.es5.tsconfig.json',
    },
    }
    ],
    },
    {
    test: /.s?css$/,
    use: ['style-loader', 'css-loader', 'sass-loader'],
    },
            {
                    test: /\.js$/,
                    use: ['react-hot', 'babel-loader'],
                    include: path.join(__dirname, 'vendor')
            },
            {
                    test: /\.(png|jpg|gif|ico)(\?v=\d+\.\d+\.\d+)?$/,
                    use: 'url-loader?limit=100000'
            },
            {
                    test: /\.(eot|com|json|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
                    use: 'url-loader?limit=10000&mimetype=application/octet-stream'
            },
            {
                    test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
                    use: 'url-loader?limit=10000&mimetype=image/svg+xml'
            },
            {
                test: /\.json$/,
                loader: 'json-loader',
            }
        ], ```
    Serrver config ---
    module: { rules: [ { test: /\.ts$/, use: [{ loader: 'ts-loader', options: { configFileName: './src/common/ts/cjs.es5.tsconfig.json', }, }], }, { test: /\.json$/, loader: 'json-loader' } ], },
    Manish Chandra
    @chandrajob365
    Any suggestion ?
    Kate
    @TheKateeeee_twitter
    Hey people, I have a problem. I think because of the daylight saving changes this weekend moment timezone is not confused and say Moment Timezone has no data for CEST. I try to add it with moment.tz.add(...) and moment.tz.load([...]) but I'm not sure where to add it exactly. I have the latest package of moment and moment timezone and running angular 5. Any suggestions?
    Jeff Voss
    @iamwhitebox
    Does anyone know how to use moment to format a date to match this date in JAVA "yyyy-MM-dd'T'HH:mm:ss'Z'"
    Mohit Anand
    @farziengineer
    Hey, is there a place new comers can discuss ?
    Jon Concepcion
    @hijoncon

    In my karma test, I am having an issue. any help with this..

    TypeError: Cannot read property 'format' of undefined

    Shane Bruggeman
    @shanebruggeman
    Hey folks, trying to use moment-timezone in ember-moment and it's attaching to window.moment instead of the moment loaded through my package.json
    I see it using the window.moment as the moment argument here:
    https://github.com/moment/moment-timezone/blob/develop/moment-timezone.js
    The else clause there
    (function (root, factory) {
        "use strict";
    
        /*global define*/
        if (typeof module === 'object' && module.exports) {
            module.exports = factory(require('moment')); // Node
        } else if (typeof define === 'function' && define.amd) {
            define(['moment'], factory);                 // AMD
        } else {
            factory(root.moment);                        // Browser
        }
    }(this, function (moment) {
    If something in ember-moment is importing / requiring in that as a module, how would they specify the arguments?