<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_previous_next_published(self, date):
 """ Returns a dict of the next and previous date periods with published entries. """

        previous_next = getattr(self, 'previous_next', None)

        if previous_next is None:
            date_year = datetime(date.year, 1, 1)
            date_month = datetime(date.year, date.month, 1)
            date_day = datetime(date.year, date.month, date.day)
            date_next_week = date_day + timedelta(weeks=1)
            previous_next = {'year': [None, None],
                             'week': [None, None],
                             'month': [None, None],
                             'day':  [None, None]}
            dates = self.get_queryset().datetimes(
                'publication_date', 'day', order='ASC')
            for d in dates:
                d_year = datetime(d.year, 1, 1)
                d_month = datetime(d.year, d.month, 1)
                d_day = datetime(d.year, d.month, d.day)
                if d_year < date_year:
                    previous_next['year'][0] = d_year.date()
                elif d_year > date_year and not previous_next['year'][1]:
                    previous_next['year'][1] = d_year.date()
                if d_month < date_month:
                    previous_next['month'][0] = d_month.date()
                elif d_month > date_month and not previous_next['month'][1]:
                    previous_next['month'][1] = d_month.date()
                if d_day < date_day:
                    previous_next['day'][0] = d_day.date()
                    previous_next['week'][0] = d_day.date() - timedelta(
                        days=d_day.weekday())
                elif d_day > date_day and not previous_next['day'][1]:
                    previous_next['day'][1] = d_day.date()
                if d_day > date_next_week and not previous_next['week'][1]:
                    previous_next['week'][1] = d_day.date() - timedelta(
                        days=d_day.weekday())

            setattr(self, 'previous_next', previous_next)
        return previous_next