From e0e4f671ae453cc373274d3d232e2754826f6ea0 Mon Sep 17 00:00:00 2001 From: Yusuf Syaifudin Date: Fri, 14 Oct 2016 15:50:21 +0700 Subject: [PATCH] change format date to 11th ... 19th until 21 --- render/render_utils.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/render/render_utils.js b/render/render_utils.js index 2fb059d..bb5a3c1 100644 --- a/render/render_utils.js +++ b/render/render_utils.js @@ -20,9 +20,14 @@ function ppDate(date) { 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'][date.getMonth()] + " " + - (function (d) { - var s = d.toString(), l = s[s.length-1]; - return s+(['st','nd','rd'][l-1] || 'th'); + (function (d) { + if(d>3 && d<21) return d + 'th'; + switch (d % 10) { + case 1: return d + 'st'; + case 2: return d + 'nd'; + case 3: return d + 'rd'; + default: return d + 'th'; + } })(date.getDate()) + ", " + date.getFullYear() + " " + date.getHours() + ":" + ("0" + date.getMinutes()).slice(-2);