keithamus / tempus

Tempus - Time for a new Date()
http://tempus-js.com
Other
94 stars 9 forks source link

Year off by 1 in tz -07:00 #17

Open caseman72 opened 12 years ago

caseman72 commented 12 years ago

This fails with the wrong Year:

Tempus.addTimeFormat({Twitter: "%a %b %d %H:%M:%S GMT%z %Y"});
var s = new Tempus("Mon Apr 10 14:45:00 GMT+0000 2012").toString("%Y-%m-%d %H:%M:%S %Z");

Expected:

2012-04-10 14:45:00 +00:00

Actual

2013-04-10 14:45:00 +00:00
keithamus commented 12 years ago

I am unable to reproduce this error on my system. Could you please tell me what operating system (and version), browser (and version) and what version (commit hash) of Tempus you are using please?

caseman72 commented 12 years ago

Latest code from github. Windows 7 + FF, Chrome and IE9

<html>
<head>
  <!--[if !IE]><!--><script src="https://raw.github.com/keithamus/Tempus/4c6491c396bd5a79b44c5bf76164712e261a21c5/tempus.js"></script><!--<![endif]-->
  <!--[if IE]><script src="./tempus.js"></script><![endif]-->
</head>
<body>
<div id="dt"></div>
<script>
  Tempus.addTimeFormat({Twitter: "%a %b %d %H:%M:%S GMT%z %Y"});
  var s = new Tempus("Mon Apr 10 14:45:00 GMT+0000 2012").toString("%Y-%m-%d %H:%M:%S %Z");
  document.getElementById("dt").innerHTML = s; // 2013-04-10 14:45:00 +00:00
</script>
</body>
</html>

Or here: http://www.manion.org/static/tempus/index.htm

keithamus commented 12 years ago

Hmm. Still getting 2012 on that site. It sounds crazy but what is your current GMT offset? ((new Date).getTimezoneOffset())

caseman72 commented 12 years ago

(new Date).getTimezoneOffset() 420

On Wed, May 23, 2012 at 2:18 PM, Keith Cirkel < reply@reply.github.com

wrote:

Hmm. Still getting 2012 on that site. It sounds crazy but what is your current GMT offset? ((new Date).getTimezoneOffset())


Reply to this email directly or view it on GitHub: https://github.com/keithamus/Tempus/issues/17#issuecomment-5884932

caseman72 commented 12 years ago

If you have Skype I can show you ... ?

caseman72 commented 12 years ago

I also used my Mac with FF, Chrome and Safari I also used my iPhone with Safari

All versions say 2013 ... ?

keithamus commented 12 years ago

I believe it to be something really strange happening with the timezone you're in. I will try to reproduce the error in a VM when I get time, for now I'll mark it as something that needs fixing for 0.2

caseman72 commented 12 years ago

This is interesting:

(new Date()).getTimezoneOffset() 420 (new Date(0)).getTimezoneOffset() 480 (new Date).getTimezoneOffset() 420

-C

On Thu, May 24, 2012 at 12:23 AM, Keith Cirkel < reply@reply.github.com

wrote:

I believe it to be something really strange happening with the timezone you're in. I will try to reproduce the error in a VM when I get time, for now I'll mark it as something that needs fixing for 0.2


Reply to this email directly or view it on GitHub: https://github.com/keithamus/Tempus/issues/17#issuecomment-5894313

caseman72 commented 12 years ago

This fixed it for me ... sets the current starting time to Jan 1, 1970 ... like it would at GMT...

Line: 313 var jan_1_offset = (new Date(0)).getTimezoneOffset() * 60E3; 314 this._date = new Date( jan_1_offset );

keithamus commented 12 years ago

The issue is that timezones are all out of whack. It requires some significant re-work of the codebase, which is going on right now on my machine and is the last blocker of 0.2.

This is effectively a dupe of #2, but you've given me lots more data to work from, so cheers!

keithamus commented 12 years ago

Could you try reproducing this error for the current master branch: b50ef5a68505359dab11e449611844896be00a0a.

caseman72 commented 12 years ago
Old version

http://www.manion.org/static/tempus/index.htm

2013-04-10 14:45:00 +00:00
New version

http://www.manion.org/static/tempus/index.b50.htm

2012-04-10 14:45:00 +00:00