I need to break down a date in python into: year, month, day and time(hour).
I have a list of objects, each object has a date property:
startDate=db.DateTimeProperty(auto_now_add=True)
The date property containts, the year, the month, the day and the time all in one.
I wish to create a new nested list(dictionary) where:
Outer list- is a list of years(that are present in at least one of the input dates) -> inside each year a list of months(that are present during that year in at least one of the input dates)-> inside this days(same as with months – days present in the input list) -> Inside that a list of times(hours)… each our pointing to it’s respective object.
I hope this is easily understood.
If I get the list bellow as input:
{obj1 -> (2000 Dec 18 9:00AM), obj2 -> (2000 Dec 19 1:00PM)}
It will clamp them together so I’ll have
(2000) -> (Dec) -> {(18) -> (9:00AM) -> obj1 ,(19) -> (1:00PM) -> obj2}
I hope this makes sense..
Basically I have a lot of events with dates and I want to list them like this:
Year ->
Month(s) of interest->
Day(s) of interest->
(event times)
.
.
.
Another Year ->
Relevant Month(s) ->
Relevant Day(s) ->
(event times)
.
.
.
Instead of:
(Event1 : complete date & time) , (Event2 : complete date & time) , (event3 : complete date & time)
Thanks
You can try producing a better formatted output:
I get output as: