# ===================================================
# How to format number for financial applications
# ===================================================

x = 12345678.4

# -------------------------------------------
# If you want put comma's in the number:
# -------------------------------------------

s = f'{x:,}'		# s is a string, you can use + to concatenate

# Alternative: s = "{:,}".format(x)
print(s)


# --------------------------------------------------------
# If you want number to end in 2 decimals in the number:
# --------------------------------------------------------

s = f'{x:.2f}'		# s is a string, you can use + to concatenate

# Alternative: s = "{:.2f}".format(x)
print(s)


# --------------------------------------------------------
# If you want BOTH features
# --------------------------------------------------------
s = f"{x:,.2f}"		# s is a string, you can use + to concatenate

# Alternative: s = "{:,.2f}".format(x)
print(s)

print("================================")

# ---------------------------------------
#


import datetime

# ----------------------------------
# Convert a string to a date
# ----------------------------------
myDate = datetime.date.fromisoformat("2022-12-01")



# ------------------------------------------------
# Convert a date to a string depending for format
# ------------------------------------------------
#
#  In general:  s = myDate.strftime("Format string")
#
# Control the formatting with a format string.
# Format string consists of a number of conversion fields
#
# Conversion fields:
#    %d: Returns day of the month, from 01 to 31 (zero padding). 
#
#    %b: Returns the first three characters of the month name. 
#    %B: Returns the full name of month 
#    %m: Returns month as a zero-padded decimal number (01,02, ... 12)
#
#    %y: Returns the year in 2-digit format (without century). 
#    %Y: Returns the year in 4-digit format. 
#
#    %H: Returns the hour. 
#    %M: Returns the minute, from 00 to 59. 
#    %S: Returns the second, from 00 to 59. 
#
# Examples:

s = myDate.strftime("%B %d %Y")		# December 01 2022
print(s)

s = myDate.strftime("%b %d %Y")		# Dec 01 2022
print(s)

s = myDate.strftime("%m/%d/%Y")		# 12/01/2022
print(s)

s = myDate.strftime("%d/%m/%Y")		# 01/12/2022
print(s)
