Skip to content

Commit

Permalink
add support to parse Do moment#1475
Browse files Browse the repository at this point in the history
```
moment('May 6th', 'MMMM Do').format('MMMM Do')
// before => May 1st
// after => May 6th
```

To assure that the patch is working as expected, a temporary
test file has been added. It can still be found at
https://gist.github.com/gr2m/3c56d1ff91bec49f547c
  • Loading branch information
gr2m committed Feb 22, 2014
1 parent aa0cbf9 commit 742ba1e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
parseTokenT = /T/i, // T (ISO separator)
parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
parseTokenOrdinal = /\d{1,2}/,

//strict parsing regexes
parseTokenOneDigit = /\d/, // 0 - 9
Expand Down Expand Up @@ -1023,6 +1024,8 @@
case 'e':
case 'E':
return parseTokenOneOrTwoDigits;
case 'Do':
return parseTokenOrdinal;
default :
a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), "i"));
return a;
Expand Down Expand Up @@ -1068,6 +1071,11 @@
datePartArray[DATE] = toInt(input);
}
break;
case 'Do' :
if (input != null) {
datePartArray[DATE] = toInt(parseInt(input, 10));
}
break;
// DAY OF YEAR
case 'DDD' : // fall through to DDDD
case 'DDDD' :
Expand Down

0 comments on commit 742ba1e

Please sign in to comment.