summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2016-04-06 23:08:45 +0200
committerhut <hut@lepus.uberspace.de>2016-04-06 23:08:49 +0200
commit800ee11b5224cf3f57e1efe7eecd8561836beefa (patch)
tree1c56bb107d104af7ea10109494aab75f32799f64
parent8a8caa40b0273186b0cdf8f8107fa56c2f82a017 (diff)
parentfcfea319bffb2aea226914ab58098bb7514a0d28 (diff)
downloadranger-800ee11b5224cf3f57e1efe7eecd8561836beefa.tar.gz
Merge branch 'mtime_linemode' of https://github.com/alphapapa/ranger into master
-rw-r--r--ranger/container/fsobject.py3
-rw-r--r--ranger/core/linemode.py21
2 files changed, 23 insertions, 1 deletions
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index db6772ac..10f8259d 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -79,7 +79,8 @@ class FileSystemObject(FileManagerAware, SettingsAware):
     _linemode = DEFAULT_LINEMODE
     linemode_dict = dict(
         (linemode.name, linemode()) for linemode in
-        [DefaultLinemode, TitleLinemode, PermissionsLinemode, FileInfoLinemode]
+        [DefaultLinemode, TitleLinemode, PermissionsLinemode, FileInfoLinemode,
+         MtimeLinemode, SizeMtimeLinemode]
     )
 
     def __init__(self, path, preload=None, path_is_abs=False, basename_is_rel_to=None):
diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py
index 76e8f7cc..b7aef23f 100644
--- a/ranger/core/linemode.py
+++ b/ranger/core/linemode.py
@@ -5,6 +5,8 @@
 
 import sys
 from abc import *
+from datetime import datetime
+from ranger.ext.human_readable import human_readable
 
 DEFAULT_LINEMODE = "filename"
 
@@ -102,3 +104,22 @@ class FileInfoLinemode(LinemodeBase):
             return fileinfo
         else:
             raise NotImplementedError
+
+class MtimeLinemode(LinemodeBase):
+    name = "mtime"
+
+    def filetitle(self, file, metadata):
+        return file.relative_path
+
+    def infostring(self, file, metadata):
+        return datetime.fromtimestamp(file.stat.st_mtime).strftime("%Y-%m-%d %H:%M")
+
+class SizeMtimeLinemode(LinemodeBase):
+    name = "sizemtime"
+
+    def filetitle(self, file, metadata):
+        return file.relative_path
+
+    def infostring(self, file, metadata):
+        return "%s %s" % (human_readable(file.size),
+                          datetime.fromtimestamp(file.stat.st_mtime).strftime("%Y-%m-%d %H:%M"))