Permalink
Browse files

format date more readable

  • Loading branch information...
1 parent 57003ea commit 2d84de480fe05698b88f31110042138333329940 @timoxley committed Mar 25, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/search.js
View
@@ -194,6 +194,11 @@ function prettify (data, args) {
return aa === bb ? 0
: aa < bb ? (searchRev ? 1 : -1)
: (searchRev ? -1 : 1)
+
+ }).map(function (line) {
+ line[3] = formatDate(line[3])
+ return line
+
}).map(function (line) {
return line.map(function (s, i) {
spaces = spaces || longest.map(function (n) {
@@ -260,3 +265,10 @@ function colorize (line) {
}
return line.split("\u0000").join("\033[0m")
}
+
+function formatDate(age) {
+ var date = new Date(age)
+ if (isNaN(date.getTime())) return age
+ var formattedDate = date.toDateString().slice(4) // chop off day
+ return formattedDate
+}

0 comments on commit 2d84de4

Please sign in to comment.