def p_period_function_month_term(p): ''' period_term : MONTH_BEFORE ''' d = month_before(date.today()) p[0] = ( _first_moment_of_month(d), _last_moment_of_month(d) ) mainlog.debug(p[0])
def _standard_period2(begin=None, end=None): mainlog.debug("IN: From {} to {}".format(begin, end)) if not end: end = date.today() if not begin: begin = month_before(end, 2) begin = _first_moment_of_month(begin) end = _last_moment_of_month(end) duration = month_diff(begin, end) mainlog.debug("From {} to {}, {} months".format(begin, end, duration)) return begin, end, duration
def refresh_action(self): # Reimplements parent method ! self.remote_indicators_service.clear_caches() mainlog.debug("Refreshing {}".format(self.month_chooser.base_date)) # begin, end = month_period_as_date(self.month_chooser.base_date) begin, end = month_before(self.month_chooser.base_date, self.MONTHS_PERIOD - 1), self.month_chooser.base_date progress = make_progress(_("Collecting data..."), sum([len(x) - 1 for x in self.indicators])) mainlog.debug("Indicator run = {}".format( self._indicators_run(self.indicators))) for ind in self._indicators_run(self.indicators): ind._gather_data(begin, end) progress.setValue(progress.value() + 1) ind.repaint() for sf in self._sub_frames: if sf.original_title(): sf.set_title(sf.original_title().replace( "%MONTH%", date_to_my(self.month_chooser.base_date, full=True)))
def month_before(self): self._set_month(month_before(self.base_date, self.step_size))
def _activate_buttons(self): self._prev_button.setEnabled( self._month_in_range(month_before(self.base_date, self.step_size))) self._next_button.setEnabled( self._month_in_range(month_after(self.base_date, self.step_size)))
def month_before(self): self.base_date = month_before(self.base_date) self.refresh_action_gui()