From d13b80b1c51a72a57e55b1584b0d34efaeedcfb7 Mon Sep 17 00:00:00 2001 From: Karl Voit Date: Thu, 4 Apr 2019 09:46:13 +0200 Subject: [PATCH] fixed ctime on macOS and closing #6 --- date2name/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/date2name/__init__.py b/date2name/__init__.py index 190f27c..75bde57 100755 --- a/date2name/__init__.py +++ b/date2name/__init__.py @@ -20,6 +20,7 @@ import time import logging import sys from optparse import OptionParser +import platform # global variables PROG_VERSION_DATE = PROG_VERSION[13:23] @@ -178,7 +179,10 @@ def get_timestamp_from_file(formatstring, item): if options.delimiter: delimiter_char = options.delimiter - if options.ctime: + if options.ctime and platform.system() == 'Darwin': + # see https://github.com/novoid/date2name/issues/6 for macOS-issue with ctime + return time.strftime(formatstring, time.localtime(os.stat(item).st_birthtime)) + delimiter_char + item + elif options.ctime and platform.system() != 'Darwin': return time.strftime(formatstring, time.localtime(os.path.getctime(item))) + delimiter_char + item elif options.mtime: return time.strftime(formatstring, time.localtime(os.path.getmtime(item))) + delimiter_char + item