-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalendar
More file actions
16 lines (15 loc) · 4.16 KB
/
Calendar
File metadata and controls
16 lines (15 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Calendar
This project intends to make a simple text-based calendar to save events and schedule plans. The calendar could simply get and save your desired events, remove them, save the calendar, read the previously saved calendar, and show the event of today as a kind of reminder as well as showing all events at the same time. The menu options are illustrated below, which is performed using ipython in CMD.
But let’s start from the beginning. When the program starts, it reads the same file as the code run to check if there is any previously saved calendar or not. The user could select one of the previously available calendars or make the new one add proposing a name for their calendar. When the appropriate option is selected, the menu appears allowing the user to modify the calendar. Option 0 allows the user to check the saved calendar again if they want to change or make another calendar or find any information inside the previous calendars.
Option 1 is designed to allow the user to define the name of the event and then insert the start and end time of the event in the format of YYYY-MM-DD HH: MM. The next option could be used to see all the saved or defined events at the same time to give a general overview to the user. More specifically, the user could use option 4 to observe the previously saved events by defining the start and end date and time in the dedicated format.
To reserve the data, option 5 is used to save the whole calendar in the same folder as the program run, which is also used to read previously saved calendars. To make the calendar more safe, by exiting the calendar using option 6, it is asked again if the user wants to save the data or not.
The code takes advantage of three imported libraries namely OS to use the operating system and read previously saved calendars in the assumed directory, JSON to save and read the calendar, and datetime to define dates and times for events. In this code, I have used various methods to divide the programming task into smaller tasks and make the programming more convenient. This also helps to identify any probable mistakes more easily with its location. The defined methods are:
- save_calendar: This is defined as used to save the calendar by the user with the allocated name by the user at the opening of the calendar and into the same directory as the code run.
- load_calendar: When the code run for the first time, this method is used to load the previously saved calendar if the user selects any of them.
- DateTime: It can take the input from the user and recognize it as a date and time when it is in the right format as it is mentioned by the program.
- NewEvent: As it was mentioned earlier, one option is to add a new event to the calendar, which is done by this method. More importantly, this method checks the input considering events overlapping and whether the end time is after the start time or not, which could commonly be inserted wrongly by a user.
- RemoveEvent: Another functional option allows the user to remove previously entered events from the calendar. The program shows the available events after using this option to allow users to remove an event by its line number and remind them which events are already in the calendar.
- Display: A method to show previously saved events in the calendar by defining the specific interval or no time to see the whole events.
- Load_or_Make_Calendar: This is used at the beginning of the code to ask the user and check the previously saved calendar in the directory of the code to be loaded or if the user wants to make a new one. There is an option inside this method that checks if there is any event today or not if the user selects to load one of the previously saved calendars.
- Option_List: This is designed to show the whole options in the calendar and it refers any selected option to the appropriate methods.
- main: This is used to run the program as it starts and have a more general overview of what is happening in the code. It shows that the code tries to load or make the calendar at the beginning and based on that the calendar shows the available options to the user. There is another safety line of code that saves the program if the user unintentionally exits the calendar by ctr+c.