Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[Date] set higher priority at new defined parsers #1100

Open
wants to merge 1 commit into from

1 participant

@danielecorti81

Using splice(0,0,… when adding parser allow to set priority at new defined parsers.

e.g. if I add a parser for European dates

Date.defileParser("%d/%m/%Y");

without this change all strings with the day under 13th of month, like 09/02/2012, will be parsed in the american date, the example will be 2 September 2012, not 9 February 2012.

@danielecorti81 danielecorti81 Using splice(0,0,… when adding parser allow to set priority at new de…
…fined parsers.

e.g. if I add a parser for European dates

Date.defileParser("%d/%m/%Y");

without this change all strings with the day under 13th of month, like 09/02/2012, will be parsed in the american date, the example will be 2 September 2012, not 9 February 2012.
9bd3a90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 10, 2012
  1. @danielecorti81

    Using splice(0,0,… when adding parser allow to set priority at new de…

    danielecorti81 authored
    …fined parsers.
    
    e.g. if I add a parser for European dates
    
    Date.defileParser("%d/%m/%Y");
    
    without this change all strings with the day under 13th of month, like 09/02/2012, will be parsed in the american date, the example will be 2 September 2012, not 9 February 2012.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  Source/Types/Date.js
View
2  Source/Types/Date.js
@@ -408,7 +408,7 @@ Date.extend({
//</1.2compat>
defineParser: function(pattern){
- parsePatterns.push((pattern.re && pattern.handler) ? pattern : build(pattern));
+ parsePatterns.splice(0,0,(pattern.re && pattern.handler) ? pattern : build(pattern));
return this;
},
Something went wrong with that request. Please try again.