Hi all,
I'm calling the
Here is the code:
What I'm expected the code to do is to change to the previous day date when the
Can you please show me an example how I could do that on my code in each time when I'm calling on the
I'm calling the
EPG_Times
function to set up the datetime date for the self.epg_time_1
, self.epg_time_2
and self.epg_time_3
to stored the time and date in the list in each time when I'm calling the EPG_Times
function. I'm also used the self.program_day
to store the value in the list, example: 0
, 1
, 2
, 3
..etc until to 6
for 7 days. When I'm calling the EPG_Times
, it will show the time with the date like this:self.epg_time_1 ['28/08/2017 11:30PM'] self.epg_time_2 ['29/08/2017 12:00AM'] self.epg_time_3 ['29/08/2017 12:30AM']So when I'm calling the
EPG_Times
function again, it will show the output like this:self.epg_time_1 ['29/08/2017 11:00PM'] self.epg_time_2 ['29/08/2017 11:30PM'] self.epg_time_3 ['29/08/2017 12:00AM']I have changed from
days = self.program_day + 1
to days = self.program_day - 1
, but when the strings show 11:00PM
, 11:30PM
and 12:00AM
from the variables epg_time_1
, epg_time_2
and epg_time_3
, it will show the contains like this:self.epg_time_1 ['27/08/2017 11:00PM'] self.epg_time_2 ['27/08/2017 11:30PM'] self.epg_time_3 ['27/08/2017 12:00AM']Here is what I'm expected to contain:
self.epg_time_1 ['28/08/2017 11:00PM'] self.epg_time_2 ['28/08/2017 11:30PM'] self.epg_time_3 ['29/08/2017 12:00AM']Then calling again.......
self.epg_time_1 ['28/08/2017 10:30PM'] self.epg_time_2 ['28/08/2017 11:00PM'] self.epg_time_3 ['28/08/2017 11:30AM']until to....
self.epg_time_1 ['27/08/2017 10:30PM'] self.epg_time_2 ['27/08/2017 11:00PM'] self.epg_time_3 ['27/08/2017 11:30AM']and so on....
Here is the code:
self.program_day = list() def EPG_Times(self): self.epg_time_1 = list() self.epg_time_2 = list() self.epg_time_3 = list() epg_time1 = str(self.getControl(344).getLabel()) epg_time2 = str(self.getControl(345).getLabel()) epg_time3 = str(self.getControl(346).getLabel()) day_date = self.program_day day = '' month = '' year = '' print "you are calling EPG_Times..........................." print day_date if day_date >= 0 and day_date <= 6: print "EPG PASSED 1..................................." print epg_time2 if epg_time3 == '12:00AM': print "EPG PASSED 2..................................." if day_date == 0: print "EPG PASSED 3..................................." if epg_time1 == '12:00AM': print "EPG PASSED 4..................................." epg_time_1 = datetime.datetime.now() + datetime.timedelta(days = self.program_day + 1) epg_time_2 = datetime.datetime.now() + datetime.timedelta(days = self.program_day + 1) epg_time_3 = datetime.datetime.now() + datetime.timedelta(days = self.program_day + 1) else: print "EPG PASSED 5..................................." epg_time_1 = datetime.datetime.now() + datetime.timedelta(days = self.program_day) epg_time_2 = datetime.datetime.now() + datetime.timedelta(days = self.program_day) epg_time_3 = datetime.datetime.now() + datetime.timedelta(days = self.program_day + 1) else: print "EPG PASSED 6..................................." currentday = datetime.datetime.now() + datetime.timedelta(days = 0) nextday = datetime.datetime.now() + datetime.timedelta(days = self.program_day) if currentday != nextday: print "you can now add the epg_time_2 and epg_time_3 next day date" epg_time_1 = datetime.datetime.now() + datetime.timedelta(days = self.program_day + 1) epg_time_2 = datetime.datetime.now() + datetime.timedelta(days = self.program_day + 1) epg_time_3 = datetime.datetime.now() + datetime.timedelta(days = self.program_day + 1) elif currentday == nextday: print "you can now add the epg_time_1, epg_time_2 and epg_time_3 next day date" epg_time_1 = datetime.datetime.now() + datetime.timedelta(days = self.program_day) epg_time_2 = datetime.datetime.now() + datetime.timedelta(days = self.program_day - 1) epg_time_3 = datetime.datetime.now() + datetime.timedelta(days = self.program_day - 1) epg1_day = epg_time_1.strftime("%d") epg1_month = epg_time_1.strftime("%m") epg1_year = epg_time_1.strftime("%Y") epg2_day = epg_time_2.strftime("%d") epg2_month = epg_time_2.strftime("%m") epg2_year = epg_time_2.strftime("%Y") epg3_day = epg_time_2.strftime("%d") epg3_month = epg_time_2.strftime("%m") epg3_year = epg_time_2.strftime("%Y") half_hour = str(epg1_day + "/" + epg1_month + "/" + epg1_year + " " + epg_time1) one_hour = str(epg2_day + "/" + epg2_month + "/" + epg2_year + " " + epg_time2) one_hour_half = str(epg3_day + "/" + epg3_month + "/" + epg3_year + " " + epg_time3) #Store the times in the list.... self.epg_time_1.append(half_hour) self.epg_time_2.append(one_hour) self.epg_time_3.append(one_hour_half)I need to use the if statement to see if the time is valid so I can control on the date whether if I need to add it to the previous day date or add it to the next day date if the time show
12:00AM
or whatever it is.What I'm expected the code to do is to change to the previous day date when the
epg_time_1
and epg_time_2
show the strings 11:00PM
and 11:30PM
. If the epg_time_3
show the string 12:00AM
then I want to add it to the next day date. If the epg_time_1
and epg_time_2
show the strings 11:30PM
and 12:00AM
, I want to change to the previous date for epg_time_1
and add it to the next day date for the epg_time_2
, because the time 12:00AM
is the next day and the time 11:30PM
is the previous day. Can you please show me an example how I could do that on my code in each time when I'm calling on the
EPG_Times
function?