Skip to content

Commit e5d8c0a

Browse files
committed
fix(PreviewPanel): Use birthtime for creation time
st_ctime does not provide accurate creation time on MacOS, and as of Python 3.12 is deprecated for Windows. On these two platforms use st_birthtime, but fall back to st_ctime on linux.
1 parent fc714e0 commit e5d8c0a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tagstudio/src/qt/widgets/preview_panel.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@ def add_field_to_selected(self, field_list: list[QModelIndex]):
492492
def update_date_label(self, filepath: Path | None = None) -> None:
493493
"""Update the "Date Created" and "Date Modified" file property labels."""
494494
if filepath and filepath.is_file():
495-
created: dt = dt.fromtimestamp(filepath.stat().st_ctime)
495+
if platform.system() == "Windows" or platform.system() == "Darwin":
496+
created: dt = dt.fromtimestamp(filepath.stat().st_birthtime)
497+
else:
498+
created: dt = dt.fromtimestamp(filepath.stat().st_ctime)
496499
modified: dt = dt.fromtimestamp(filepath.stat().st_mtime)
497500
self.date_created_label.setText(
498501
f"<b>Date Created:</b> {dt.strftime(created, "%a, %x, %X")}"

0 commit comments

Comments
 (0)