Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Modification time(mtime) to date #17

Open
davideuler opened this issue May 6, 2022 · 0 comments
Open

Modification time(mtime) to date #17

davideuler opened this issue May 6, 2022 · 0 comments

Comments

@davideuler
Copy link
Owner

davideuler commented May 6, 2022

What is the most idiomatic/efficient way to convert from a modification time retrieved from stat() call to a datetime object?
https://stackoverflow.com/questions/39359245/from-stat-st-mtime-to-datetime

from datetime import datetime, timedelta, timezone
from pathlib import Path

path = Path('foo')
path.touch()
statResult = path.stat()

modified = datetime.fromtimestamp(stat_result.st_mtime, tz=timezone.utc)
print('modified', modified)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant