Option to show 4 digit years
I notice that fman currently always shows 2 digit years in the Modified column. I would like an option to keep the short date/time format exactly as specified in the locale rather than having fman mangle it
You will be able to implement this yourself as a plugin once #294 is implemented. Then, you can simply copy/paste the code you referenced and remove the "mangling". Some pointers for then:
I would love to be able to format the date and time in ISO 8601 format (YYYY-MM-DD HH:MM:SS). If there is a way to do this, please let me know
@blokeley you could write a plugin that overwrites the get_str(...) method of the Modified column: https://github.com/fman-users/Core/blob/20d328a67fbd13d1adcf840f8b158040bfb3730f/core/init.py#L92
Something like
from core import Modified
def my_get_str(self, url):
# Make changes here
try:
mtime = self._get_mtime(url)
except OSError:
return ''
if mtime is None:
return ''
try:
timestamp = mtime.timestamp()
except OSError:
# This can occur in at least Python 3.6 on Windows. To reproduce:
# datetime.min.timestamp()
# This raises `OSError: [Errno 22] Invalid argument`.
return ''
mtime_qt = QDateTime.fromMSecsSinceEpoch(int(timestamp * 1000))
time_format = QLocale().dateTimeFormat(QLocale.ShortFormat)
# Always show two-digit years, not four digits:
time_format = time_format.replace('yyyy', 'yy')
return mtime_qt.toString(time_format)
Modified.get_str = my_get_str
Thanks @mherrmann If anyone else wants the datetime in ISO 8601 format (YYYY-MM-DD HH:MM to minute resolution) then here is the code I used in a plugin:
from core import Modified
def get_iso_datetime(self, url):
try:
mtime = self._get_mtime(url)
except OSError:
return ''
return mtime.isoformat(sep=' ', timespec='minutes') if mtime else ''
Modified.get_str = get_iso_datetime