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