Skip to content

Commit eef29f9

Browse files
committed
Merge pull request locutusjs#69 from menzoic/patch-1
Update functions/datetime/date.js
2 parents 687ceb3 + 19eeec2 commit eef29f9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

functions/datetime/date.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ function date (format, timestamp) {
8989
N: function () { // ISO-8601 day of week; 1[Mon]..7[Sun]
9090
return f.w() || 7;
9191
},
92-
S: function () { // Ordinal suffix for day of month; st, nd, rd, th
93-
var j = f.j();
94-
return j < 4 | j > 20 && (['st', 'nd', 'rd'][j % 10 - 1] || 'th');
92+
S: function(){ // Ordinal suffix for day of month; st, nd, rd, th
93+
var j = f.j()
94+
i = j%10;
95+
if (i <= 3 && parseInt((j%100)/10) == 1) i = 0;
96+
return ['st', 'nd', 'rd'][i - 1] || 'th';
9597
},
9698
w: function () { // Day of week; 0[Sun]..6[Sat]
9799
return jsdate.getDay();

0 commit comments

Comments
 (0)