@@ -192,6 +192,22 @@ Format.size = function(size)
192192 return string.format (' %.2f%s' , size , ' B' )
193193end
194194
195+ Format .friendly_time = function (timestamp )
196+ local now = os.time ()
197+ local diff = now - timestamp
198+ if diff < 60 then
199+ return string.format (' %d secs ago' , diff )
200+ elseif diff < 3600 then
201+ return string.format (' %d mins ago' , math.floor (diff / 60 ))
202+ elseif diff < 86400 then
203+ return string.format (' %d hours ago' , math.floor (diff / 3600 ))
204+ elseif diff < 86400 * 14 then -- two weeks show "X days ago"
205+ return string.format (' %d days ago' , math.floor (diff / 86400 ))
206+ else
207+ return os.date (' %Y %b %d' , timestamp )
208+ end
209+ end
210+
195211-- Notification system
196212local function notify_wrapper (level )
197213 return function (msg )
@@ -217,7 +233,7 @@ UI.Entry = {
217233 perms = Format .permissions (entry .stat .mode ),
218234 user = Format .username (entry .stat .uid ),
219235 size = Format .size (entry .stat .size ),
220- time = os.date ( ' %Y-%m-%d %H:%M ' , entry .stat .mtime .sec ),
236+ time = Format . friendly_time ( entry .stat .mtime .sec ),
221237 name = entry .name .. (entry .stat .type == ' directory' and SEPARATOR or ' ' ),
222238 }
223239 api .nvim_buf_set_lines (
0 commit comments