Highlights
Task:
When making back up of data files or log files, it is a very common practice to name the backup directories and/or files based on the date the backup was done. In order to restore or locate the directory/file, we often need to find out the backup date from today's date.
The computational task for this assignment is to design an algorithm and write a python script according to your algorithm with appropriate functions. The script should take two dates in the "DD- MM-YYYY" format and return the number of days from the first to the second date. That is, if the user enters "18-06-2020" and "25-06-2020", the script will return "7". Similarly, if the target date is in the past, the script will return a negative number.
In addition, if the user enters one date only, then the number returned should be the number of days between today's date and the specified date.
Required Modules and Functions
Your python script is allowed to import only the os, subprocess and sys modules from the standard library and all the built-in functions.
Based on the algorithm you have designed for this assignment, you should at least have the following four functions defined in your python script (see later section on the purpose of each function) in order to get a passing grade for this assignment:
dbda()
after()
before()
today()
You should also create additional functions to improved the re-usability of your python code by adding the following functions to earn the maximum possible mark for this assignment:
days_in_mon()
leap_year()
valid_date()
usage()
python3 assign.py 01-01-2019 02-01-2019, and the output should be1
python3 assign.py 01-01-2019 31-12-2018, and the output should be -1
python3 assign.py 01-06-2020, and since today is June 3, the output should be 2
python3 assign.py 01-01-2019 01-01-2020, and the output should be 365
python3 assign.py 01-01-2021 01-01-2020 , and the output should be -366
python3 assign.py 01-13-2018, and the output should be
Error: wrong month entered
python3 assign.py 99-01-2020 01-01-2020, and the output should be
Error: wrong day entered
python3 assign.py 2018 2, and the output should be
Error: wrong date entered
If there is too few or too many command line arguments given, display the proper usage:
Usage: assign.py DD-MM-YYYY [DD-MM-YYYY] >/code> Script structure and sample template
The following is a brief description of each function:
The dbda() function should be the main function of your script. The dbda() function will take two dates in "DD-MM-YYYY" format, and return an integer that corresponds to the number of days between the given dates. If the start date is earlier than the stop date, the number is positive. If start date is later than the stop date, the number is negative. Your dbda() function should delegate the actual calculation of the target date to either the after() function or the before() function.
The today() function will be called if the user has not specified a second argument. It will return your Linux computer's local time in the format DD-MM-YYYY. Hint: you may need to read man pages for a shell command in order to return a usable date. You may also use string formatting to modify output.
The before() function will take a date in "DD-MM-YYYY" format and return the date of the previous day in the same format.
The after() function will take a date in "DD-MM-YYYY" format and return the date of the next day in the same format. Next paragraph is a sample
python code for the after() function. To earn the maximum possible mark for the assignment, you should modify the sample after() function to make use of the days_in_mon() function.
The leap_year() function will take a year in "YYYY" format, and return True if the given year is a leap year, otherwise return False.
The valid_date() function will take a date in "DD-MM-YYYY" format, and return True if the given date is a valid date, otherwise return False plus an appropriate status message. The valid_date() function should make use of the days_in_mon() function.
The days_in_mon() function will take a year in "YYYY" format, and return a dictionary object which contains
This IT Assignment has been solved by our IT Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.