How to show full date and time in Nautilus/Files 3.6+ list view?
You can get back the full date by recompiling nautilus:
sudo apt-get build-dep nautilus
sudo apt-get install quilt
export QUILT_PATCHES=debian/patches
apt-get source nautilus
cd nautilus*
quilt new 999_full_dates.patch
quilt edit libnautilus-private/nautilus-column-utilities.c
Change line 77 from
"attribute", "date_modified",
to
"attribute", "date_modified_full",
Rebuild and install modified package:
quilt refresh
fakeroot dpkg-buildpackage
cd ..
killall nautilus
sudo dpkg -i nautilus_*.deb
nautilus &
As always, you have to perform these steps every time there is an update for nautilus in Ubuntu.
Now, a full analysis of the problem:
The actual patch which caused this change is this one.
The function nautilus_file_get_date_as_string
gains an extra gboolean parameter "compact" - when true the abbreviated date is returned.
This function is never called directly - it is accessed through the wrapper function nautilus_file_get_string_attribute_q
. This function takes attribute parameters like "date_modified". To accommodate the new signature of nautilus_file_get_date_as_string
a new attribute is added "date_modified_full
". After this change, any code in nautilus which uses the file date string will get the abbreviated date.
Finally, the file properties dialog is updated to use "date_modified_full" attribute.
So in order to have nautilus display the full date in list view, it is only necessary to change one line of code: in libnautilus-private/nautilus-column-utilities.c, line 77 from "date_modified" to "date_modified_full".
A slightly more useful patch could add a new column type which would show the full date, making this an optional feature, and only add 10 lines of code.
This blog post shows a much easier solution. It is based on creating an extension which can be selected as an alternative "modified column". Tested under 16.04.
gedit ~/.local/share/nautilus-python/extensions/longdate.py
Use this code (always copy code you trust):
#!/usr/bin/env python import os import urllib import datetime from gi.repository import Nautilus, GObject class ColumnExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.InfoProvider): def __init__(self): pass def get_columns(self): return (Nautilus.Column( name="NautilusPython::Longdate", attribute="longdate", label="Longdate", description="Get long date"),) def update_file_info(self, file): if file.get_uri_scheme() != 'file': return filename = urllib.unquote(file.get_uri()[7:]) statbuf = os.stat(filename) formatteddate = datetime.datetime.fromtimestamp(statbuf.st_mtime).strftime('%Y-%m-%d %H:%M:%S') file.add_string_attribute('longdate', str(formatteddate))
chmod +x ~/.local/share/nautilus-python/extensions/longdate.py
sudo apt install python-nautilus
nautilus -q
andnautilus .
to restart Nautilus and see if it properly loads the extension.Select the new "Longdate" column in the list column preferences.
The result will look like this:
For those using trusty
& not wishing to compile I've set up a test ppa for a patched nautilus. (using Alistair Buxton's patch
The build currently also includes 2 bug fix patches, 1 from trusty-proposed, 1 from utopic.
Additionally there are 3 minor patches that have been tested by me over quite some time & pose no issues.
open with on folders
real file owner name displayed instead of "Me"
File Manager as name of launcher
The 'date-time' patch I've tested a bit, seen no issues. For those inclined to try - if any issue found contact me thru launchpad email.
The "Modified (full)" column can be added thru nautilus in listview
> View > Visible Columns.. or thru nautilus > Edit > Preferences > List Columns
https://launchpad.net/~mc3man/+archive/nauty-mods
Read ppa page for info & how to easily revert if need be.