<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">"""
    -------------------------------------------------------
    Takes self hour, self day of month, and those of another
    person. Outputs a string with the hour difference and
    description of whether the other user is ahead or behind
    self.
     
    Use:  get_hr_diff(12, 13, 12, 5)
    -------------------------------------------------------
    Preconditions:
      self_day - day of month of self (int)
      other_day - day of month of other person (int)
      self_hour - hour of day of self (int)
      other_hour - hour of day of other (int)
    Postconditions:
      td_msg - the hour difference and ahead/behind (str)
    ------------------------------------------------------- 

"""

def get_hr_diff(self_day, other_day, self_hour, other_hour):
    
    if self_day &lt; 1 or other_day &lt; 1 or self_day &gt; 31 or other_day &gt; 31 or self_hour &lt; 0 or self_hour &gt; 23 or other_hour &lt; 0 or other_hour &gt; 23:
        return "Hour difference cannot be displayed"

    day_delta = abs(other_day-self_day)

    if day_delta &gt; 2: # Month wraparound has occurred (up to 26 hrs diff)

        # Other is 1 or more days ahead
        if other_day &lt;= 2:
            td_msg = str(other_hour+(other_day-1)*24+24-self_hour) + " hours ahead of you"

        # Should never happen
        elif other_day &gt; 2:
            td_msg = "Hour difference cannot be displayed"

        # I am 1 or more days ahead
        else:
            td_msg = str(self_hour+(self_day-1)*24+24-other_hour) + " hours behind you"

    elif day_delta &gt; 0: # Different days but no month wraparound (&lt;= 26 hrs)

        if other_day &gt; self_day:
            td_msg = str(other_hour+(day_delta-1)*24+24-self_hour) + " hours ahead of you"

        else:
            td_msg = str(self_hour+(day_delta-1)*24+24-other_hour) + " hours behind you"

    else: # If we get here, it must be the same day

        if other_hour &gt; self_hour:
            td_msg = str(other_hour-self_hour)+ " hours ahead of you"

        elif self_hour &gt; other_hour:
            td_msg = str(self_hour-other_hour)+ " hours behind you"

        else: # Hey buddy, we're in the same timezone!
            td_msg = "Same time as you"

    return td_msg</pre></body></html>