Skip to content

Commit b3e7dd4

Browse files
Fixed case with single 'd' and multiple 'd'
1 parent 4fab5d6 commit b3e7dd4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/filters/ordinalDate/ordinalDate.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ angular.module( 'angularUtils.filters.ordinalDate', [] )
99
};
1010

1111
return function(timestamp, format) {
12-
var regex = /d(?=[^d])((?!\w*(?='))(?!d))/g;
12+
var regex = /d+((?!\w*(?=')))|d$/g;
1313
var date = new Date(timestamp);
1414
var dayOfMonth = date.getDate();
1515
var suffix = getOrdinalSuffix(dayOfMonth);
1616

17-
format = format.replace(regex, suffix);
17+
format = format.replace(regex, (match) => {
18+
return match === "d" ? suffix : match;
19+
});
1820
return $filter('date')(date, format);
1921
};
2022
}]);

0 commit comments

Comments
 (0)