norminette

This commit is contained in:
hugogogo
2025-10-28 21:33:13 +01:00
parent 17b1da0822
commit 1ebc36c197
9 changed files with 53 additions and 29 deletions

View File

@@ -1,16 +1,29 @@
import datetime as dt
import time as tm
# https://docs.python.org/3.10/library/datetime.html?highlight=time#datetime.datetime
now = dt.datetime.now()
epoch = dt.datetime(1970, 1, 1)
# # for memory
# epoch = dt.datetime(1970, 1, 1)
# delta = now - epoch
# deltaInSeconds = delta.total_seconds()
# https://docs.python.org/3.10/library/datetime.html?highlight=time#strftime-and-strptime-behavior
formatDate = now.strftime("%b %d %Y")
format_date = now.strftime("%b %d %Y")
delta = now - epoch
epoch_delta_in_seconds = tm.time()
deltaInSeconds = delta.total_seconds()
deltaInSecondsStr = "{:,.3f}".format(float(deltaInSeconds))
deltaInScientificStr = "{:.2e}".format(float(deltaInSeconds))
# str.format https://docs.python.org/3.10/library/string.html#formatstrings
epoch_delta_in_seconds_str = "{:,.4f}".format(epoch_delta_in_seconds)
epoch_delta_in_scientific_str = "{:.2e}".format(epoch_delta_in_seconds)
print("Seconds since January 1, 1970: " + deltaInSecondsStr + " or " + deltaInScientificStr + " in scientific notation\n" + formatDate)
print(
"Seconds since January 1, 1970: ",
epoch_delta_in_seconds_str,
" or ",
epoch_delta_in_scientific_str,
" in scientific notation\n",
format_date,
sep=""
)