This commit is contained in:
cwx
2023-04-07 10:35:25 +08:00
parent da76a2ce17
commit 83142498b3
3 changed files with 13 additions and 12 deletions
+9 -7
View File
@@ -195,17 +195,19 @@ class imageUtils:
print("remove=",imgpath)
class fileUtils:
@classmethod
def getModificationDate(cls,file_path):
return os.path.getmtime(file_path)
def getModificationDate(cls,file_path,format="%Y%m%d",not_exists=None):
if cls.notExists(file_path): return not_exists
file_date = os.path.getmtime(file_path)
s = time.localtime(file_date)
format_date = time.strftime(format,s)
print(f"file={file_path} {format_date}")
return format_date
@classmethod
def getModificationDateYMD(cls,file_path,not_exists="9999"):
if cls.notExists(file_path): return not_exists
file_date = cls.getModificationDate(file_path)
s = time.localtime(file_date)
ymd = time.strftime("%Y%m%d",s)
print(f"file={file_path} {ymd}")
ymd = cls.getModificationDate(file_path,"%Y%m%d",not_exists)
return int(ymd)
@classmethod