Exemplo n.º 1
0
 def prepare_period(self, config: 'DocumentDigestConfig', dst_user: User, run_date: datetime.datetime) \
         -> Tuple[datetime.datetime, datetime.datetime]:
     period_start = (run_date - datetime.timedelta(days=run_date.weekday())) \
         .replace(hour=0, minute=0, second=0, microsecond=0)
     return period_start.astimezone(
         dst_user.get_time_zone()), run_date.astimezone(
             dst_user.get_time_zone())
Exemplo n.º 2
0
 def prepare_period(self, config: 'DocumentDigestConfig', dst_user: User, run_date: datetime.datetime) \
         -> Tuple[datetime.datetime, datetime.datetime]:
     this_day_start = run_date.replace(hour=0,
                                       minute=0,
                                       second=0,
                                       microsecond=0)
     prev_day_start = this_day_start - datetime.timedelta(days=1)
     return prev_day_start.astimezone(
         dst_user.get_time_zone()), this_day_start.astimezone(
             dst_user.get_time_zone())
Exemplo n.º 3
0
    def prepare_period(self, config: 'DocumentDigestConfig', dst_user: User, run_date: datetime.datetime) \
            -> Tuple[datetime.datetime, datetime.datetime]:
        period_start = DocumentDigestSendDate.objects \
            .filter(config=config, to=dst_user).order_by('-date').values_list('date', flat=True).first()

        if not period_start:
            period_start = (run_date - datetime.timedelta(days=run_date.weekday())) \
                .replace(hour=0, minute=0, second=0, microsecond=0)

        return period_start.astimezone(
            dst_user.get_time_zone()), run_date.astimezone(
                dst_user.get_time_zone())