Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datejs 1.0.0-rc3 has inconsistent timezone behavior between Date().parse().set({ hour: 0 }).toISOString() and .toString("yyyy-MM-ddTHH:mm:ss.sssZ") for certain datestrings #254

Open
JamesMcGuigan opened this issue Feb 25, 2016 · 0 comments

Comments

@JamesMcGuigan
Copy link

Datejs 1.0.0-rc3 has inconsistent timezone behavior between Date().parse().set({ hour: 0 }).toISOString() and .toString("yyyy-MM-ddTHH:mm:ss.sssZ") for certain datestrings

2009-07-31T00:00:00.000Z is one known example, which outputs as
2009-07-30T23:00:00.000Z with .set({ hour: 0 }).toISOString()
2009-07-31T01:00:00.000Z with .toString() but is fixed with .set({ hour: 0 })

Karma/chai unit test attached - tested in OSX Phantomjs, Chrome, Safari

describe('Datejs 1.0.0-rc3 - date-en-GB.js - for dateString: "2009-07-31T00:00:00.000Z"', function() {

  it('Datejs.parse().toISOString() - passes', function() {
    expect(Date.parse("2009-07-31T00:00:00.000Z").toISOString()).to.equal("2009-07-31T00:00:00.000Z");
  });
  it('Datejs.parse().toString("yyyy-MM-ddTHH:mm:ss.sssZ")) - fails', function() {
    // AssertionError: expected '2009-07-31T01:00:00.000Z' to equal '2009-07-31T00:00:00.000Z'
    expect(Date.parse("2009-07-31T00:00:00.000Z").toString("yyyy-MM-ddTHH:mm:ss.sssZ")).to.equal("2009-07-31T00:00:00.000Z");
  });


  it('Datejs.parse().set({ millisecond: 0, second: 0, minute: 0 }).toISOString() - passes', function() {
    expect(Date.parse("2009-07-31T00:00:00.000Z").set({ millisecond: 0, second: 0, minute: 0 }).toISOString()).to.equal("2009-07-31T00:00:00.000Z");
  });
  it('Datejs.parse().set({ millisecond: 0, second: 0, minute: 0 }).toString("yyyy-MM-ddTHH:mm:ss.sssZ")) - fails', function() {
    // AssertionError: expected '2009-07-31T01:00:00.000Z' to equal '2009-07-31T00:00:00.000Z'
    expect(Date.parse("2009-07-31T00:00:00.000Z").set({ millisecond: 0, second: 0, minute: 0 }).toString("yyyy-MM-ddTHH:mm:ss.sssZ")).to.equal("2009-07-31T00:00:00.000Z");
  });


  it('Datejs.parse().set({ hour: 0 }).toISOString() - fails', function() {
    // AssertionError: expected '2009-07-30T23:00:00.000Z' to equal '2009-07-31T00:00:00.000Z'
    expect(Date.parse("2009-07-31T00:00:00.000Z").set({ hour: 0 }).toISOString()).to.equal("2009-07-31T00:00:00.000Z");
  });
  it('Datejs.parse().set({ hour: 0 }).toString("yyyy-MM-ddTHH:mm:ss.sssZ")) - passes', function() {
    expect(Date.parse("2009-07-31T00:00:00.000Z").set({ hour: 0 }).toString("yyyy-MM-ddTHH:mm:ss.sssZ")).to.equal("2009-07-31T00:00:00.000Z");
  });


  it('Datejs.parse().clearTime().toISOString() - fails', function() {
    // AssertionError: expected '2009-07-30T23:00:00.000Z' to equal '2009-07-31T00:00:00.000Z'
    expect(Date.parse("2009-07-31T00:00:00.000Z").clearTime().toISOString()).to.equal("2009-07-31T00:00:00.000Z");
  });
  it('Datejs.parse().clearTime().toString() - passes', function() {
    expect(Date.parse("2009-07-31T00:00:00.000Z").clearTime().toString("yyyy-MM-ddTHH:mm:ss.sssZ")).to.equal("2009-07-31T00:00:00.000Z");
  });

});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant