mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 15:49:09 +00:00
fix(ui): use birthtime for creation time on mac & win (#472)
* 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. * mypy errors
This commit is contained in:
@@ -492,7 +492,11 @@ class PreviewPanel(QWidget):
|
||||
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)
|
||||
created: dt = None
|
||||
if platform.system() == "Windows" or platform.system() == "Darwin":
|
||||
created = dt.fromtimestamp(filepath.stat().st_birthtime) # type: ignore[attr-defined]
|
||||
else:
|
||||
created = dt.fromtimestamp(filepath.stat().st_ctime)
|
||||
modified: dt = dt.fromtimestamp(filepath.stat().st_mtime)
|
||||
self.date_created_label.setText(
|
||||
f"<b>Date Created:</b> {dt.strftime(created, "%a, %x, %X")}"
|
||||
|
||||
Reference in New Issue
Block a user