1earner1 commited on
Commit
5acc411
·
verified ·
1 Parent(s): 952f22e

Upload filetime.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. filetime.py +20 -0
filetime.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import platform
3
+ import datetime
4
+
5
+ def get_creation_date(path):
6
+ # if platform.system() == 'Windows':
7
+ # return datetime.datetime.fromtimestamp(os.path.getctime(path))
8
+ # else:
9
+ # # On Linux/Unix, return last metadata change time
10
+ stat = os.stat(path)
11
+ print(stat)
12
+ # try:
13
+ # return datetime.datetime.fromtimestamp(stat.st_birthtime) # macOS
14
+ # except AttributeError:
15
+ # Linux fallback
16
+ return datetime.datetime.fromtimestamp(stat.st_ctime)
17
+
18
+ # Example
19
+ file_path = "run_lora_chat.py"
20
+ print("Creation time:", get_creation_date(file_path))