JosephMajaseSithole / datejs

Automatically exported from code.google.com/p/datejs
0 stars 0 forks source link

[FIXED] toString hour field fails for 12am #24

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open console window
2  new Date(2007,11,16,0,51,53).toString("MMMM dd, yyyy - hh:mm tt")

What is the expected output? What do you see instead?
I see "December 16, 2007 - 00:51 AM"
I expect "December 16, 2007 - 12:51 AM"

What version of the product are you using? On what operating system?
Alpha1. All browsers produce the same. 

Please provide any additional information below.
To fix this, go to line core-debug.js line 604 - 602

Change it to 
        case "hh":
            return p(self.getHours() < 13 ? (self.getHours() == 0 ? 12 : self.getHours()) : 
(self.getHours() - 12));
        case "h":
            return self.getHours() < 13 ? (self.getHours() == 0 ? 12 : self.getHours()) : (self.getHours() 
- 12);

I've attached a fixed version of latest_alpha1. It includes a unit test to 
diagnose and fix the 
problem.

Thanks

Original issue reported on code.google.com by jcnet...@gmail.com on 22 Dec 2007 at 12:59

Attachments:

GoogleCodeExporter commented 8 years ago
Correction: core-debug.js lines 604 - 607

Original comment by jcnet...@gmail.com on 22 Dec 2007 at 1:00

GoogleCodeExporter commented 8 years ago
Attaching the unit test to replicate the problem

Original comment by jcnet...@gmail.com on 22 Dec 2007 at 1:01

Attachments:

GoogleCodeExporter commented 8 years ago
Attaching the fixed core-debug.js

Original comment by jcnet...@gmail.com on 22 Dec 2007 at 1:02

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for reporting the bug. It's weird that this bug was even in there, 
because I
explicitly remember fixing this once before. At some point that code must have 
been
overwritten. We should have had a test in place.

Thanks for the test case as well. I added your test to the Test Suite and 
stubbed out
a few more just to get things started. See 
http://www.datejs.com/test/tostring/index.html

The new .toString() code has been committed to SVN is available at
http://datejs.googlecode.com/svn/trunk/src/core-debug.js

Original comment by geoff%co...@gtempaccount.com on 22 Dec 2007 at 1:09