From e5d8c0acd09cfd364b964e483c2dbaf68b11e348 Mon Sep 17 00:00:00 2001 From: Sean Krueger Date: Sat, 7 Sep 2024 20:51:50 -0500 Subject: [PATCH] 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. --- tagstudio/src/qt/widgets/preview_panel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tagstudio/src/qt/widgets/preview_panel.py b/tagstudio/src/qt/widgets/preview_panel.py index cf02d45fd..72d00e6a3 100644 --- a/tagstudio/src/qt/widgets/preview_panel.py +++ b/tagstudio/src/qt/widgets/preview_panel.py @@ -492,7 +492,10 @@ def add_field_to_selected(self, field_list: list[QModelIndex]): def update_date_label(self, filepath: Path | None = None) -> None: """Update the "Date Created" and "Date Modified" file property labels.""" if filepath and filepath.is_file(): - created: dt = dt.fromtimestamp(filepath.stat().st_ctime) + if platform.system() == "Windows" or platform.system() == "Darwin": + created: dt = dt.fromtimestamp(filepath.stat().st_birthtime) + else: + created: dt = dt.fromtimestamp(filepath.stat().st_ctime) modified: dt = dt.fromtimestamp(filepath.stat().st_mtime) self.date_created_label.setText( f"Date Created: {dt.strftime(created, "%a, %x, %X")}"