From e9b31175f6d1429e636aec64a7d05ac108514131 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Sat, 25 Oct 2025 17:48:22 +0200 Subject: [PATCH] ex01 ok --- d00/ex01/format_ft_time.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 d00/ex01/format_ft_time.py diff --git a/d00/ex01/format_ft_time.py b/d00/ex01/format_ft_time.py new file mode 100644 index 0000000..9cdaec3 --- /dev/null +++ b/d00/ex01/format_ft_time.py @@ -0,0 +1,16 @@ +import datetime as dt + +# https://docs.python.org/3.10/library/datetime.html?highlight=time#datetime.datetime +now = dt.datetime.now() +epoch = dt.datetime(1970, 1, 1) + +# https://docs.python.org/3.10/library/datetime.html?highlight=time#strftime-and-strptime-behavior +formatDate = now.strftime("%b %d %Y") + +delta = now - epoch + +deltaInSeconds = delta.total_seconds() +deltaInSecondsStr = "{:,.3f}".format(float(deltaInSeconds)) +deltaInScientificStr = "{:.2e}".format(float(deltaInSeconds)) + +print("Seconds since January 1, 1970: " + deltaInSecondsStr + " or " + deltaInScientificStr + " in scientific notation\n" + formatDate) \ No newline at end of file