pingjiang / datejs

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

Logic for 12:00 AM/PM is backwards #141

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Date.parseExact('12:12 AM', 'h:mm tt').toString('yyyy-MM-dd HH:mm:ss'); // 
returns '2011-12-01 12:12:00'
2. Date.parseExact('12:12 PM', 'h:mm tt').toString('yyyy-MM-dd HH:mm:ss'); // 
returns '2011-12-02 00:12:00'

What is the expected output? What do you see instead?

I should get:
1. '12:00 AM' => '2011-12-01 00:12:00'
2. '12:00 PM' => '2011-12-02 12:12:00'

Instead I get:
1. '12:00 AM' => '2011-12-01 12:12:00'
2. '12:00 PM' => '2011-12-02 00:12:00'

What version of the product are you using? On what operating system?
Version: 1.0 Alpha-1 
Build Date: 13-Nov-2007
Win-d'oh!s Vista
Firefox 8.0

Please provide any additional information below.

The logic for 12:00 AM/PM is backwards:
  * 12:00 AM is supposed to be equal to 00:00 hours (midnight)
  * 12:00 PM is supposed to be equal to 12:00 hours (noon/midday)

It looks like 12:00 PM is also wrapping to the next day, which it shouldn't 
since it is supposed to be the middle of the current day.

Original issue reported on code.google.com by JianHouZi on 29 Dec 2011 at 2:03

GoogleCodeExporter commented 9 years ago
Problem is solved if you download and use the date.js file found in the 
project's home page source (version: 1.0 Alpha-1, build date: 2008-05-13) 
instead of the the file listed for public download (Version: 1.0 Alpha-1, Build 
Date: 13-Nov-2007).

Original comment by JianHouZi on 29 Dec 2011 at 2:58

GoogleCodeExporter commented 9 years ago
Find the following:

if(this.meridian&&this.hour){this.hour=(this.hour<13&&this.meridian=="p")?this.h
our+12:this.hour;}

...and change to:

if(this.meridian&&this.hour){this.hour=(this.hour<12&&this.meridian=="p")?this.h
our+12:this.hour;}

Original comment by michael....@ne0ge0.com on 1 Jul 2013 at 11:31

GoogleCodeExporter commented 9 years ago
Fixed in current build on my fork: https://github.com/abritinthebay/datejs

Original comment by darkcr...@gmail.com on 10 Sep 2013 at 12:02