'programming a journal in python without calender module. what is the most appropriate way to program dates, must be able to skip empty pages

I must build a journal, but I don't understand how to implement dates. I have to be able to sort the dates appropriately.

Do I turn months into lists with everyday of each month in the list? I still need to sort properly.

The assignment refers to the time module (not the datetime module)

Its a journal, every entry must be written to a specific date, time doesn't matter. I must be able to flip the pages back and forth and edit the already made entries but empty pages must be skipped. I don't need exact code just some tips for how to achieve this.



Solution 1:[1]

At this point, it would be easier to understand the question if you'd post the whole assignment text.

One guess you're being asked to create a date object from scratch and then write some code to allow for iterating across it. If that is the case, then number all the days from a known epoch, e.g. Jan 1, 1970. Anyhow, that sounds too challenging for an new programmer so I probably misunderstand your assignment. (Here are alternatives to pythons built in datetime libs: https://opensource.com/article/18/4/python-datetime-libraries )

Or you are just being asked to work with the Date object & iterate across the days. It also sounds like you need to implement some UI, probably with input(), and some in memory data structure like a dictionary with the date as a key and journal entries as values, e.g.

journal = {
date(2002, 12, 31): "had some tea",
date(2002, 5, 31): "took a nap"
}
sorted_journal = sorted(journal)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MatthewMartin