diff options
Diffstat (limited to 'public/assets/js')
| -rw-r--r-- | public/assets/js/lib/views/index/threadbox.js | 2 | ||||
| -rw-r--r-- | public/assets/js/util/format.js | 34 |
2 files changed, 34 insertions, 2 deletions
diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js index 069f85d..2e7d211 100644 --- a/public/assets/js/lib/views/index/threadbox.js +++ b/public/assets/js/lib/views/index/threadbox.js @@ -33,7 +33,7 @@ var ThreadBox = View.extend({ .replace(/{{username}}/g, thread.username) .replace(/{{privacy_dot}}/g, dot) .replace(/{{title}}/g, thread.title) - .replace(/{{age}}/g, get_age(thread.lastmodified) ) + .replace(/{{age}}/g, verbose_date(thread.lastmodified) ) .replace(/{{age_class}}/g, carbon_date(thread.lastmodified) ) .replace(/{{views}}/g, views[1]) .replace(/{{comments}}/g, comments[1]) diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index 7c773d4..90a19d2 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -21,8 +21,40 @@ function privacy_dot (p) { else return "·:" } +var short_months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ") +function verbose_date (date) { + var date = new Date(date * 1000) + var d = date.getDate() + var m = date.getMinutes() + var h = date.getHours() + var meridian + + if (h == 0) { + h = 12 + meridian = " am" + } + else if (h == 12) { + meridian = " pm" + } + else if (h > 12) { + h -= 12 + meridian = " pm" + } + else { + meridian = " am" + } + + if (d < 10) d = "0" + d + if (m < 10) m = "0" + m + if (h < 10) h = "0" + h + + var date = d + '-' + short_months[date.getMonth()] + '-' + date.getFullYear() + var time = h + ':' + m + meridian + + return date + " <small>" + time + "</small>" +} function carbon_date (date, no_bold) { - var span = (+new Date() - date * 1000) + var span = (+new Date() / 1000 - date) if (! no_bold && span < 86400) // modified today { color = "new" } else if (span < 604800) // modifed this week |
