In: Computer Science
Must be in python
The ISO 8601 Standard date format for Information Interchange indicates that a date be written as such:
yyyy-MM-dd (eg. 2012-07-02, 1999-12-05, 1998 -01-27 )
where yyyy represents the four digit year
MM represents a two digit numerical month
dd represents a two digit numerical day
Chinese date format is specified as: yyyy-M-d
Macedonean date format is specified as: d.M.yyyy.
where yyyy represents the four digit year
M represents a one or two digit numerical month, as appropriate
d represents a one or two digit numerical day, as appropriate
You are to write a program which converts dates from Chinese and Macedonean formats to ISO format. The program will repeat the following until the user wishes to exit:
* ask the user which format they will be entering (C - Chinese or M-Macedonean)
* accept the user input
* output the ISO version of the date that was input
Your program should handle user input errors such as:
* leading blanks
* blanks within the input string
Your program should delegate any large operations to functions which should be DEFINED AN IMPORTED MODULE, for example month conversion to mFormat, MMformat.
KEYNOTES:-
PROGRAM: -
OUTPUT: -
PROGRAM CODE:-
import datetime
ch='\O'
while(ch!='E'):
print("\nPRESS C TO ENTER THE CHINESE DATE FORMAT")
print("PRESS M TO ENTER THE MACEDONEAN DATE FORMAT")
print("PRESS E TO EXIT",)
ch=input("ENTER YOUR CHOICE : ")
if(ch=='C'):
print("\n**YOUR HAVE SELECTED TO ENTER YOUR DATE IN CHINESE
FORMAT**")
year = int(input('ENTER THE YEAR : '))
month = int(input('ENTER THE MONTH : '))
day = int(input('ENTER THE DAY : '))
date1 = datetime.date(year, month, day)
print("\nYOUR ENTERED DATE IN CHINESE FORMAT IS
:",year,end="-")
print(month,end="-")
print(day)
print("THE ISO VERSION OF THIS DATE IS :",date1)
elif(ch=='M'):
print("\n**YOUR HAVE SELECTED TO ENTER YOUR DATE IN MACEDONEAN
FORMAT**")
day = int(input('ENTER THE DAY : '))
month = int(input('ENTER THE MONTH : '))
year = int(input('ENTER THE YEAR : '))
date1 = datetime.date(year, month, day)
print("\nYOUR ENTERED DATE IN MACEDONEAN FORMAT IS
:",day,end=".")
print(month,end=".")
print(year)
print("THE ISO VERSION OF DATE IS :",date1)
elif(ch=='E'):
print("\n**THANKYOU**")