Ejemplo n.º 1
0
    def callback(self):
        if self.abs_seconds >= _to_abs_seconds(days=6, hours=1):
            return None
        time_in_words = []
        days = self.kwargs.get('days')
        hours = self.kwargs.get('hours')
        minutes = self.kwargs.get('minutes')

        if hours < 1:
            time_in_words.append(
                _append_unit_suffix(days, self.loc.day_singular,
                                    self.loc.day_plural))
        elif hours < 10:
            time_in_words.append(self.loc.a_little_more_than)
            time_in_words.append(
                _append_unit_suffix(days, self.loc.day_singular,
                                    self.loc.day_plural))
        elif hours < 14:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(days, self.loc.day_singular,
                                    self.loc.day_plural, self.loc.half))
        elif hours < 23:
            time_in_words.append(self.loc.a_little_less_than)
            time_in_words.append(
                _append_unit_suffix(days + 1, self.loc.day_singular,
                                    self.loc.day_plural))
        else:
            time_in_words.append(
                _append_unit_suffix(days + 1, self.loc.day_singular,
                                    self.loc.day_plural))

        return " ".join(time_in_words)
Ejemplo n.º 2
0
    def callback(self):
        if self.abs_seconds >= _to_abs_seconds(years=10):
            return None
        time_in_words = []
        years = self.kwargs.get('years')
        months = self.kwargs.get('months')

        if months < 1:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years, self.loc.year_singular,
                                    self.loc.year_plural))
        elif months < 4:
            time_in_words.append(self.loc.more_than)
            time_in_words.append(
                _append_unit_suffix(years, self.loc.year_singular,
                                    self.loc.year_plural))
        elif months < 8:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years, self.loc.year_singular,
                                    self.loc.year_plural, self.loc.half))
        elif months < 11:
            time_in_words.append(self.loc.less_than)
            time_in_words.append(
                _append_unit_suffix(years + 1, self.loc.year_singular,
                                    self.loc.year_plural))
        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years + 1, self.loc.year_singular,
                                    self.loc.year_plural))

        return " ".join(time_in_words)
Ejemplo n.º 3
0
    def callback(self):
        if self.abs_seconds >= _to_abs_seconds(years=10):
            return None
        time_in_words = []
        years = self.kwargs.get('years')
        months = self.kwargs.get('months')

        if months < 1:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years, self.loc.year_singular,
                                    self.loc.year_plural))
        elif months < 4:
            time_in_words.append(self.loc.more_than)
            time_in_words.append(
                _append_unit_suffix(years, self.loc.year_singular,
                                    self.loc.year_plural))
        elif months < 8:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years, self.loc.year_singular,
                                    self.loc.year_plural, self.loc.half))
        elif months < 11:
            time_in_words.append(self.loc.less_than)
            time_in_words.append(
                _append_unit_suffix(years + 1, self.loc.year_singular,
                                    self.loc.year_plural))
        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years + 1, self.loc.year_singular,
                                    self.loc.year_plural))

        return " ".join(time_in_words)
Ejemplo n.º 4
0
    def callback(self):
        if self.abs_seconds >= _to_abs_seconds(months=11):
            return None

        time_in_words = []
        months = self.kwargs.get('months')
        weeks = self.kwargs.get('weeks')
        days = self.kwargs.get('days')

        if weeks < 1:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(months, self.loc.month_singular,
                                    self.loc.month_plural))

        elif _to_abs_seconds(weeks=weeks, days=days) <\
                _to_abs_seconds(months=1) - _to_abs_seconds(weeks=1):
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(months, self.loc.month_singular,
                                    self.loc.month_plural, self.loc.half))
        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(months + 1, self.loc.month_singular,
                                    self.loc.month_plural))
        return " ".join(time_in_words)
Ejemplo n.º 5
0
    def callback(self):
        if self.abs_seconds >= _to_abs_seconds(months=11):
            return None

        time_in_words = []
        months = self.kwargs.get('months')
        weeks = self.kwargs.get('weeks')
        days = self.kwargs.get('days')

        if weeks < 1:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(months, self.loc.month_singular,
                                    self.loc.month_plural))

        elif _to_abs_seconds(weeks=weeks, days=days) <\
                _to_abs_seconds(months=1) - _to_abs_seconds(weeks=1):
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(months, self.loc.month_singular,
                                    self.loc.month_plural, self.loc.half))
        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(months + 1, self.loc.month_singular,
                                    self.loc.month_plural))
        return " ".join(time_in_words)
Ejemplo n.º 6
0
    def callback(self):
        time_in_words = []
        years = self.kwargs.get('years')
        months = self.kwargs.get('months')

        if months < 6:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years, self.loc.year_singular,
                                    self.loc.year_plural))
        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years + 1, self.loc.year_singular,
                                    self.loc.year_plural))

        return " ".join(time_in_words)
Ejemplo n.º 7
0
    def callback(self):
        time_in_words = []
        years = self.kwargs.get('years')
        months = self.kwargs.get('months')

        if months < 6:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years, self.loc.year_singular,
                                    self.loc.year_plural))
        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(years + 1, self.loc.year_singular,
                                    self.loc.year_plural))

        return " ".join(time_in_words)
Ejemplo n.º 8
0
    def callback(self):
        # Less than a minute
        if self.abs_seconds >= _to_abs_seconds(minutes=1):
            return None

        time_in_words = []
        seconds = self.kwargs.get('seconds')
        time_in_words.append(
            _append_unit_suffix(seconds, self.loc.second_singular,
                                self.loc.second_plural))
        return " ".join(time_in_words)
Ejemplo n.º 9
0
    def callback(self):
        # Less than a minute
        if self.abs_seconds >= _to_abs_seconds(minutes=1):
            return None

        time_in_words = []
        seconds = self.kwargs.get('seconds')
        time_in_words.append(_append_unit_suffix(seconds,
                                                 self.loc.second_singular,
                                                 self.loc.second_plural))
        return " ".join(time_in_words)
Ejemplo n.º 10
0
    def callback(self):
        # Between 1 minute and one hour
        if self.abs_seconds >= _to_abs_seconds(hours=1):
            return None

        time_in_words = []
        minutes = self.kwargs['minutes']
        time_in_words.append(self.loc.about)
        time_in_words.append(
            _append_unit_suffix(minutes, self.loc.minute_singular,
                                self.loc.minute_plural))
        return " ".join(time_in_words)
Ejemplo n.º 11
0
    def callback(self):
        # Between 1 minute and one hour
        if self.abs_seconds >= _to_abs_seconds(hours=1):
            return None

        time_in_words = []
        minutes = self.kwargs['minutes']
        time_in_words.append(self.loc.about)
        time_in_words.append(_append_unit_suffix(minutes,
                                                 self.loc.minute_singular,
                                                 self.loc.minute_plural))
        return " ".join(time_in_words)
Ejemplo n.º 12
0
    def callback(self):
        # Between 1 hour and 23 hours
        if self.abs_seconds >= _to_abs_seconds(hours=23):
            return None

        time_in_words = []
        hours = self.kwargs.get('hours')
        minutes = self.kwargs.get('minutes')
        if minutes <= 5:
            time_in_words.append(self.loc.about)
            time_in_words.append(_append_unit_suffix(hours,
                                                     self.loc.hour_singular,
                                                     self.loc.hour_plural))

        elif minutes < 25:
            time_in_words.append(self.loc.more_than)
            time_in_words.append(_append_unit_suffix(hours,
                                                     self.loc.hour_singular,
                                                     self.loc.hour_plural))

        elif minutes <= 35:
            time_in_words.append(_append_unit_suffix(hours,
                                                     self.loc.hour_singular,
                                                     self.loc.hour_plural,
                                                     self.loc.half))
        elif minutes < 55:
            time_in_words.append(self.loc.less_than)
            time_in_words.append(_append_unit_suffix(hours + 1,
                                                     self.loc.hour_singular,
                                                     self.loc.hour_plural))

        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(_append_unit_suffix(hours + 1,
                                                     self.loc.hour_singular,
                                                     self.loc.hour_plural))

        return " ".join(time_in_words)
Ejemplo n.º 13
0
    def callback(self):
        # Between 1 hour and 23 hours
        if self.abs_seconds >= _to_abs_seconds(hours=23):
            return None

        time_in_words = []
        hours = self.kwargs.get('hours')
        minutes = self.kwargs.get('minutes')
        if minutes <= 5:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(hours, self.loc.hour_singular,
                                    self.loc.hour_plural))

        elif minutes < 25:
            time_in_words.append(self.loc.more_than)
            time_in_words.append(
                _append_unit_suffix(hours, self.loc.hour_singular,
                                    self.loc.hour_plural))

        elif minutes <= 35:
            time_in_words.append(
                _append_unit_suffix(hours, self.loc.hour_singular,
                                    self.loc.hour_plural, self.loc.half))
        elif minutes < 55:
            time_in_words.append(self.loc.less_than)
            time_in_words.append(
                _append_unit_suffix(hours + 1, self.loc.hour_singular,
                                    self.loc.hour_plural))

        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(hours + 1, self.loc.hour_singular,
                                    self.loc.hour_plural))

        return " ".join(time_in_words)
Ejemplo n.º 14
0
    def callback(self):
        if self.abs_seconds >= _to_abs_seconds(days=6, hours=1):
            return None
        time_in_words = []
        days = self.kwargs.get('days')
        hours = self.kwargs.get('hours')
        minutes = self.kwargs.get('minutes')

        if hours < 1:
            time_in_words.append(_append_unit_suffix(days,
                                                     self.loc.day_singular,
                                                     self.loc.day_plural))
        elif hours < 10:
            time_in_words.append(self.loc.a_little_more_than)
            time_in_words.append(
                _append_unit_suffix(days,
                                    self.loc.day_singular,
                                    self.loc.day_plural))
        elif hours < 14:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(days,
                                    self.loc.day_singular,
                                    self.loc.day_plural,
                                    self.loc.half))
        elif hours < 23:
            time_in_words.append(self.loc.a_little_less_than)
            time_in_words.append(
                _append_unit_suffix(days + 1,
                                    self.loc.day_singular,
                                    self.loc.day_plural))
        else:
            time_in_words.append(_append_unit_suffix(days + 1,
                                                     self.loc.day_singular,
                                                     self.loc.day_plural))

        return " ".join(time_in_words)
Ejemplo n.º 15
0
    def callback(self):
        if self.abs_seconds >= _to_abs_seconds(days=25, hours=10):
            return None
        time_in_words = []
        weeks = self.kwargs.get('weeks')
        days = self.kwargs.get('days')

        if days < 2:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(weeks, self.loc.week_singular,
                                    self.loc.week_plural))
        elif days < 5:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(weeks, self.loc.week_singular,
                                    self.loc.week_plural, self.loc.half))
        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(weeks + 1, self.loc.week_singular,
                                    self.loc.week_plural))

        return " ".join(time_in_words)
Ejemplo n.º 16
0
    def callback(self):
        if self.abs_seconds >= _to_abs_seconds(days=25, hours=10):
            return None
        time_in_words = []
        weeks = self.kwargs.get('weeks')
        days = self.kwargs.get('days')

        if days < 2:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(weeks, self.loc.week_singular,
                                    self.loc.week_plural))
        elif days < 5:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(weeks, self.loc.week_singular,
                                    self.loc.week_plural, self.loc.half))
        else:
            time_in_words.append(self.loc.about)
            time_in_words.append(
                _append_unit_suffix(weeks + 1, self.loc.week_singular,
                                    self.loc.week_plural))

        return " ".join(time_in_words)