{"action":"created","issue":{"url":"https://api.github.com/repos/ranger/ranger/issues/1364","repository_url":"https://api.github.com/repos/ranger/ranger","labels_url":"https://api.github.com/repos/ranger/ranger/issues/1364/labels{/name}","comments_url":"https://api.github.com/repos/ranger/ranger/issues/1364/comments","events_url":"https://api.github.com/repos/ranger/ranger/issues/1364/events","html_url":"https://github.com/ranger/ranger/issues/1364","id":374775574,"node_id":"MDU6SXNzdWUzNzQ3NzU1NzQ=","number":1364,"title":"[Feature suggestion] Add human friendly display format for dates","user":{"login":"joelostblom","id":4560057,"node_id":"MDQ6VXNlcjQ1NjAwNTc=","avatar_url":"https://avatars0.githubusercontent.com/u/4560057?v=4","gravatar_id":"","url":"https://api.github.com/users/joelostblom","html_url":"https://github.com/joelostblom","followers_url":"https://api.github.com/users/joelostblom/followers","following_url":"https://api.github.com/users/joelostblom/following{/other_user}","gists_url":"https://api.github.com/users/joelostblom/gists{/gist_id}","starred_url":"https://api.github.com/users/joelostblom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelostblom/subscriptions","organizations_url":"https://api.github.com/users/joelostblom/orgs","repos_url":"https://api.github.com/users/joelostblom/repos","events_url":"https://api.github.com/users/joelostblom/events{/privacy}","received_events_url":"https://api.github.com/users/joelostblom/received_events","type":"User","site_admin":false},"labels":[{"id":22402,"node_id":"MDU6TGFiZWwyMjQwMg==","url":"https://api.github.com/repos/ranger/ranger/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ranger/ranger/milestones/1","html_url":"https://github.com/ranger/ranger/milestone/1","labels_url":"https://api.github.com/repos/ranger/ranger/milestones/1/labels","id":3896175,"node_id":"MDk6TWlsZXN0b25lMzg5NjE3NQ==","number":1,"title":"v1.9.3","description":null,"creator":{"login":"toonn","id":1486805,"node_id":"MDQ6VXNlcjE0ODY4MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/1486805?v=4","gravatar_id":"","url":"https://api.github.com/users/toonn","html_url":"https://github.com/toonn","followers_url":"https://api.github.com/users/toonn/followers","following_url":"https://api.github.com/users/toonn/following{/other_user}","gists_url":"https://api.github.com/users/toonn/gists{/gist_id}","starred_url":"https://api.github.com/users/toonn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toonn/subscriptions","organizations_url":"https://api.github.com/users/toonn/orgs","repos_url":"https://api.github.com/users/toonn/repos","events_url":"https://api.github.com/users/toonn/events{/privacy}","received_events_url":"https://api.github.com/users/toonn/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2018-12-13T09:35:33Z","updated_at":"2018-12-13T09:35:34Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2018-10-28T17:06:56Z","updated_at":"2018-12-17T23:44:31Z","closed_at":null,"author_association":"NONE","body":"\r\nThanks for making ranger, it such an efficient file browser!\r\n\r\nOne thing that I like from file managers such as Nautilus and Thunar is the\r\noption to display dates in a more human friendly format, e.g. \"21 Oct\" or\r\n\"Mon\":\r\n\r\n![image](https://user-images.githubusercontent.com/4560057/47619040-4bb6fb00-da97-11e8-8a8f-1c25bd9d9fa9.png)\r\n\r\nThis was really easy to add to ranger thanks to the custom line mode\r\nfunctionality and I thought it could be nice to have as options in the default\r\ninstallation also for those that prefer not to write their own linemodes and\r\nfor increased discoverability. I think this format facilitates getting a quick\r\noverview compared to the more verbose default date format:\r\n\r\nOld style:\r\n![image](https://user-images.githubusercontent.com/4560057/47619016-ff6bbb00-da96-11e8-845c-c499677e64a2.png)\r\n\r\nSuggested style:\r\n![image](https://user-images.githubusercontent.com/4560057/47619004-c7647800-da96-11e8-817a-d22514645a5c.png)\r\n\r\nLet me know if this is something you are interested in and I can submit a PR.\r\n\r\n<details>\r\n<summary>Here is the code for the line mode</summary>\r\n\r\n```python\r\nfrom datetime import datetime\r\nimport ranger.api\r\nimport ranger.core.linemode\r\n\r\n\r\n@ranger.api.register_linemode\r\nclass MyLinemode(ranger.core.linemode.LinemodeBase):\r\n    name = \"human_mtime\"\r\n\r\n    def filetitle(self, fobj, metadata):\r\n        return fobj.relative_path\r\n\r\n    def infostring(self, fobj, metadata):\r\n        if fobj.stat is None:\r\n            return '?'\r\n        file_date = datetime.fromtimestamp(fobj.stat.st_mtime)\r\n        time_diff = datetime.now().date() - file_date.date()\r\n        if time_diff.days > 364:\r\n            return file_date.strftime(\"%-d %b %Y\")\r\n        if time_diff.days > 6:\r\n            return file_date.strftime(\"%-d %b\")\r\n        elif time_diff.days >= 1:\r\n            return file_date.strftime(\"%a\")\r\n        else:\r\n            return file_date.strftime(\"%H:%M\")\r\n```\r\n\r\nI also made one for the size and this date format (padded with whitespace\r\nso that the sizes still line up in a column)\r\n\r\n```python\r\nfrom datetime import datetime\r\nimport ranger.api\r\nimport ranger.core.linemode\r\nfrom ranger.ext.human_readable import human_readable\r\n\r\n\r\n@ranger.api.register_linemode\r\nclass MyLinemode(ranger.core.linemode.LinemodeBase):\r\n    name = \"size_human_mtime\"\r\n\r\n    def filetitle(self, fobj, metadata):\r\n        return fobj.relative_path\r\n\r\n    def infostring(self, fobj, metadata):\r\n        if fobj.stat is None:\r\n            return '?'\r\n        size = human_readable(fobj.size)\r\n        file_date = datetime.fromtimestamp(fobj.stat.st_mtime)\r\n        time_diff = datetime.now().date() - file_date.date()\r\n        if time_diff.days > 364:\r\n            return \"%s %11s\" % (size, file_date.strftime(\"%-d %b %Y\"))\r\n        if time_diff.days > 6:\r\n            return \"%s %11s\" % (size, file_date.strftime(\"%-d %b\"))\r\n        elif time_diff.days >= 1:\r\n            return \"%s %11s\" % (size, file_date.strftime(\"%a\"))\r\n        else:\r\n            return \"%s %11s\" % (size, file_date.strftime(\"%H:%M\"))\r\n```\r\n\r\nIf ranger is being used on 31 Dec on a leap year, e.g. 2020, this would display\r\nfiles modified on Jan 1st the same year as \"1 Jan 2020\" rather than just \"1\r\nJan\". This can be avoided by adding a check for leap years:\r\n\r\n\r\n```python\r\n        if file_date.year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):\r\n            days_in_year = 365\r\n        else:\r\n            days_in_year = 364\r\n```\r\n\r\nBut this is to accommodate an even that *might* happen on one day every\r\n4 years... Not sure if it is needed.\r\n\r\nFinally a short note that Thunar and Nautilus does not use the exact same human readable date\r\nformat. My implementation is closer to the Nautilus style with the main\r\ndeviation being that I use the three weekday letter abbreviation instead of\r\n\"Yesterday\" since I think it looks neater (but willing to change if someone\r\nfeels strongly about this).\r\n\r\n</details>\r\n"},"comment":{"url":"https://api.github.com/repos/ranger/ranger/issues/comments/448041775","html_url":"https://github.com/ranger/ranger/issues/1364#issuecomment-448041775","issue_url":"https://api.github.com/repos/ranger/ranger/issues/1364","id":448041775,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODA0MTc3NQ==","user":{"login":"dllud","id":1716156,"node_id":"MDQ6VXNlcjE3MTYxNTY=","avatar_url":"https://avatars1.githubusercontent.com/u/1716156?v=4","gravatar_id":"","url":"https://api.github.com/users/dllud","html_url":"https://github.com/dllud","followers_url":"https://api.github.com/users/dllud/followers","following_url":"https://api.github.com/users/dllud/following{/other_user}","gists_url":"https://api.github.com/users/dllud/gists{/gist_id}","starred_url":"https://api.github.com/users/dllud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dllud/subscriptions","organizations_url":"https://api.github.com/users/dllud/orgs","repos_url":"https://api.github.com/users/dllud/repos","events_url":"https://api.github.com/users/dllud/events{/privacy}","received_events_url":"https://api.github.com/users/dllud/received_events","type":"User","site_admin":false},"created_at":"2018-12-17T23:44:31Z","updated_at":"2018-12-17T23:44:31Z","author_association":"NONE","body":"@joelostblom You are right on spot. The included `mtime` also breaks when displaying that directory. I am using `jmtpfs`. The first directory it shows under the mount point, named `Internal storage`, has this strange date value.\r\nI am opening a bug report with `jmtpfs`.\r\nThere are already opened issues for ranger that are related: #1020 and #1180"}}
{"actor":{"display_login":"dllud"}}