summaryrefslogtreecommitdiff
path: root/app/client/util/format.js
diff options
context:
space:
mode:
authorJules <jules@asdf.us>2018-09-22 10:47:50 -0400
committerJules <jules@asdf.us>2018-09-22 10:47:50 -0400
commit7e39114e27520e382f26368ae8f4d08ae7f3071b (patch)
tree01e7f210b0c3a119622e92d56d01f5c7951ad631 /app/client/util/format.js
parent46889933fd9c36c527014410823e88a7d838d239 (diff)
parent8d1c19852fcce52e369978dfc195d5da4f12180a (diff)
merge
Diffstat (limited to 'app/client/util/format.js')
-rw-r--r--app/client/util/format.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/app/client/util/format.js b/app/client/util/format.js
index e436a3e..ee1f47f 100644
--- a/app/client/util/format.js
+++ b/app/client/util/format.js
@@ -38,6 +38,22 @@ export function carbon_date (date, no_bold) {
{ color = "quiet" }
return color
}
+export function carbon_time (date, no_bold) {
+ var span = (+new Date() - new Date(date)) / 1000, color
+ if (! no_bold && span < 3600) // modified this hour
+ { color = "new" }
+ else if (span < 3 * 3600) // modifed last 3 hours
+ { color = "recent" }
+ else if (span < 12 * 3600) // modifed last 12 hours
+ { color = "med" }
+ else if (span < 24 * 3600) // modifed last day
+ { color = "old" }
+ else if (span < 48 * 3600) // modifed last two days
+ { color = "older" }
+ else
+ { color = "quiet" }
+ return color
+}
export function hush_views (n, bias, no_bold) {
var txt = commatize(n, 1000)
bias = bias || 1
@@ -71,21 +87,19 @@ export function hush_size (n, bias, no_bold) {
if (n < 1000000) {
return ["quiet", txt + " kb."]
}
- else if (n < (20000000/bias)) {
+ if (n < (20000000/bias)) {
return ["quiet", txt + " mb."]
}
- else if (n < (50000000/bias)) {
+ if (n < (50000000/bias)) {
return ["old", txt + " mb."]
}
- else if (n < (80000000/bias)) {
+ if (n < (80000000/bias)) {
return ["med", txt + " mb."]
}
- else if (no_bold || n < (170000000/bias)) {
+ if (no_bold || n < (170000000/bias)) {
return ["recent", txt + " mb."]
}
- else {
- return ["new", txt + " mb."]
- }
+ return ["new", txt + " mb."]
}
export function hush_null (n, unit, no_bold) {
var s = unit ? n + " " + unit + "." : n