Closed Bug 1175778 Opened 9 years ago Closed 9 months ago

Date.parse chokes on a period after abbreviated month

Categories

(Core :: JavaScript: Standard Library, enhancement)

38 Branch
enhancement

Tracking

()

RESOLVED FIXED
118 Branch
Tracking Status
firefox118 --- fixed

People

(Reporter: jgbishop, Assigned: vinny.diehl)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome, parity-ie)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Build ID: 20150525141253

Steps to reproduce:

The Date.parse() routine can't handle a period after an abbreviated name, which occurs in the Associated Press style date format (e.g. "Aug.", "Sept.", "Oct.", etc). I found this while debugging a Django application (Django uses AP format by default for date fields).

Chrome and IE 11 both handle the periods just fine.


Actual results:

Date.parse('Aug. 15, 2015') // Results in NaN


Expected results:

A valid value should be returned.
Severity: normal → enhancement
Whiteboard: [parity-chrome][parity-IE]
Component: General → JavaScript Engine
Product: Firefox → Core
Lovely.  The spec says:

  The function first attempts to parse the format of the String according to the rules
  (including extended years) called out in Date Time String Format (20.3.1.16). If the
  String does not conform to that format the function may fall back to any
  implementation-specific heuristics or implementation-specific date formats.
  Unrecognizable Strings or dates containing illegal element values in the format String
  shall cause Date.parse to return NaN.

So per spec our behavior is totally fine.  Gotta love not-so-useful specs.  :(
Component: JavaScript Engine → JavaScript: Standard Library
Mass bug change to replace various 'parity' whiteboard flags with the new canonical keywords. (See bug 1443764 comment 13.)
Whiteboard: [parity-chrome][parity-IE]
Severity: normal → S3

This is fixed trivially by ignoring '.' at the top level of the parse loop, as we do with commas and spaces. I have a patch incoming. :)

Assignee: nobody → vinny.diehl
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #9345541 - Attachment description: Bug 1175778 - Allow '.' in `Date.parse` r?#spidermonkey-reviewers → Bug 1175778 - Allow '.' in `Date.parse` r?arai
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/331879c52f18
Allow '.' in `Date.parse` r=arai
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: