Skip to content

Commit cba0cc0

Browse files
committed
Fixes singular for negative values of intervals.
Fixes #14
1 parent e184c60 commit cba0cc0

File tree

29 files changed

+187
-179
lines changed

29 files changed

+187
-179
lines changed

pendulum/interval.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ def months(self):
6666

6767
@property
6868
def weeks(self):
69-
return self.days // 7
69+
return abs(self.days) // 7 * self._sign(self._days)
7070

7171
@property
7272
def days(self):
7373
return self._days
7474

7575
@property
7676
def days_exclude_weeks(self):
77-
return self._days % 7 * self._sign(self._days)
77+
return abs(self._days) % 7 * self._sign(self._days)
7878

7979
@property
8080
def hours(self):
@@ -100,7 +100,7 @@ def minutes(self):
100100
def seconds(self):
101101
if self._s is None:
102102
self._s = self._seconds
103-
self._s = self._s % 60 * self._sign(self._s)
103+
self._s = abs(self._s) % 60 * self._sign(self._s)
104104

105105
return self._s
106106

pendulum/lang/af.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
},
5353

5454
# Units of time
55-
'year': ['1 jaar', '{count} jare'],
56-
'month': ['1 maand', '{count} maande'],
57-
'week': ['1 week', '{count} weke'],
58-
'day': ['1 dag', '{count} dae'],
59-
'hour': ['1 uur', '{count} ure'],
60-
'minute': ['1 minuut', '{count} minute'],
61-
'second': ['1 sekond', '{count} sekondes'],
55+
'year': ['{count} jaar', '{count} jare'],
56+
'month': ['{count} maand', '{count} maande'],
57+
'week': ['{count} week', '{count} weke'],
58+
'day': ['{count} dag', '{count} dae'],
59+
'hour': ['{count} uur', '{count} ure'],
60+
'minute': ['{count} minuut', '{count} minute'],
61+
'second': ['{count} sekond', '{count} sekondes'],
6262

6363
# Relative time
6464
'ago': '{time} terug',

pendulum/lang/bg.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
},
5353

5454
# Units of time
55-
'year': ['1 година', '{count} години'],
56-
'month': ['1 месец', '{count} месеца'],
57-
'week': ['1 седмица', '{count} седмици'],
58-
'day': ['1 ден', '{count} дни'],
59-
'hour': ['1 час', '{count} часа'],
60-
'minute': ['1 минута', '{count} минути'],
61-
'second': ['1 секунда', '{count} секунди'],
55+
'year': ['{count} година', '{count} години'],
56+
'month': ['{count} месец', '{count} месеца'],
57+
'week': ['{count} седмица', '{count} седмици'],
58+
'day': ['{count} ден', '{count} дни'],
59+
'hour': ['{count} час', '{count} часа'],
60+
'minute': ['{count} минута', '{count} минути'],
61+
'second': ['{count} секунда', '{count} секунди'],
6262

6363
# Relative time
6464
'ago': 'преди {time}',

pendulum/lang/ca.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
},
5353

5454
# Units of time
55-
'year': ['1 any', '{count} anys'],
56-
'month': ['1 mes', '{count} mesos'],
57-
'week': ['1 setmana', '{count} setmanes'],
58-
'day': ['1 dia', '{count} díes'],
59-
'hour': ['1 hora', '{count} hores'],
60-
'minute': ['1 minut', '{count} minuts'],
61-
'second': ['1 segon', '{count} segons'],
55+
'year': ['{count} any', '{count} anys'],
56+
'month': ['{count} mes', '{count} mesos'],
57+
'week': ['{count} setmana', '{count} setmanes'],
58+
'day': ['{count} dia', '{count} díes'],
59+
'hour': ['{count} hora', '{count} hores'],
60+
'minute': ['{count} minut', '{count} minuts'],
61+
'second': ['{count} segon', '{count} segons'],
6262

6363
# Relative time
6464
'ago': 'Fa {time}',

pendulum/lang/cs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
},
5353

5454
# Units of time
55-
'year': ['1 rok', '{count} roky', '{count} let'],
56-
'month': ['1 měsíc', '{count} měsíce', '{count} měsíců'],
57-
'week': ['1 týden', '{count} týdny', '{count} týdnů'],
58-
'day': ['1 den', '{count} dny', '{count} dní'],
59-
'hour': ['1 hodina', '{count} hodiny', '{count} hodin'],
60-
'minute': ['1 minuta', '{count} minuty', '{count} minut'],
61-
'second': ['1 sekunda', '{count} sekundy', '{count} sekund'],
55+
'year': ['{count} rok', '{count} roky', '{count} let'],
56+
'month': ['{count} měsíc', '{count} měsíce', '{count} měsíců'],
57+
'week': ['{count} týden', '{count} týdny', '{count} týdnů'],
58+
'day': ['{count} den', '{count} dny', '{count} dní'],
59+
'hour': ['{count} hodina', '{count} hodiny', '{count} hodin'],
60+
'minute': ['{count} minuta', '{count} minuty', '{count} minut'],
61+
'second': ['{count} sekunda', '{count} sekundy', '{count} sekund'],
6262

6363
# Relative time
6464
'ago': '{time} nazpět',

pendulum/lang/da.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
},
5353

5454
# Units of time
55-
'year': ['1 år', '{count} år'],
56-
'month': ['1 måned', '{count} måneder'],
57-
'week': ['1 uge', '{count} uger'],
58-
'day': ['1 dag', '{count} dage'],
59-
'hour': ['1 time', '{count} timer'],
60-
'minute': ['1 minut', '{count} minutter'],
61-
'second': ['1 sekund', '{count} sekunder'],
55+
'year': ['{count} år', '{count} år'],
56+
'month': ['{count} måned', '{count} måneder'],
57+
'week': ['{count} uge', '{count} uger'],
58+
'day': ['{count} dag', '{count} dage'],
59+
'hour': ['{count} time', '{count} timer'],
60+
'minute': ['{count} minut', '{count} minutter'],
61+
'second': ['{count} sekund', '{count} sekunder'],
6262

6363
# Relative time
6464
'ago': '{time} siden',

pendulum/lang/de.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,27 @@
5252
},
5353

5454
# Units of time
55-
'year': ['1 Jahr', '{count} Jahre'],
56-
'month': ['1 Monat', '{count} Monate'],
57-
'week': ['1 Woche', '{count} Wochen'],
58-
'day': ['1 Tag', '{count} Tage'],
59-
'hour': ['1 Stunde', '{count} Stunden'],
60-
'minute': ['1 Minute', '{count} Minuten'],
61-
'second': ['1 Sekunde', '{count} Sekunden'],
55+
'year': ['{count} Jahr', '{count} Jahre'],
56+
'month': ['{count} Monat', '{count} Monate'],
57+
'week': ['{count} Woche', '{count} Wochen'],
58+
'day': ['{count} Tag', '{count} Tage'],
59+
'hour': ['{count} Stunde', '{count} Stunden'],
60+
'minute': ['{count} Minute', '{count} Minuten'],
61+
'second': ['{count} Sekunde', '{count} Sekunden'],
6262

6363
# Relative time
6464
'ago': 'vor {time}',
6565
'from_now': 'in {time}',
6666
'after': '{time} später',
6767
'before': '{time} zuvor',
6868

69-
'year_from_now': ['1 Jahr', '{count} Jahren'],
70-
'month_from_now': ['1 Monat', '{count} Monaten'],
71-
'week_from_now': ['1 Woche', '{count} Wochen'],
72-
'day_from_now': ['1 Tag', '{count} Tagen'],
73-
'year_ago': ['1 Jahr', '{count} Jahren'],
74-
'month_ago': ['1 Monat', '{count} Monaten'],
75-
'week_ago': ['1 Woche', '{count} Wochen'],
76-
'day_ago': ['1 Tag', '{count} Tagen'],
69+
'year_from_now': ['{count} Jahr', '{count} Jahren'],
70+
'month_from_now': ['{count} Monat', '{count} Monaten'],
71+
'week_from_now': ['{count} Woche', '{count} Wochen'],
72+
'day_from_now': ['{count} Tag', '{count} Tagen'],
73+
'year_ago': ['{count} Jahr', '{count} Jahren'],
74+
'month_ago': ['{count} Monat', '{count} Monaten'],
75+
'week_ago': ['{count} Woche', '{count} Wochen'],
76+
'day_ago': ['{count} Tag', '{count} Tagen'],
7777
}
7878

pendulum/lang/el.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
},
5353

5454
# Units of time
55-
'year': ['1 χρόνος', '{count} χρόνια'],
56-
'month': ['1 μήνας', '{count} μήνες'],
57-
'week': ['1 εβδομάδα', '{count} εβδομάδες'],
58-
'day': ['1 μέρα', '{count} μέρες'],
59-
'hour': ['1 ώρα', '{count} ώρες'],
60-
'minute': ['1 λεπτό', '{count} λεπτά'],
61-
'second': ['1 δευτερόλεπτο', '{count} δευτερόλεπτα'],
55+
'year': ['{count} χρόνος', '{count} χρόνια'],
56+
'month': ['{count} μήνας', '{count} μήνες'],
57+
'week': ['{count} εβδομάδα', '{count} εβδομάδες'],
58+
'day': ['{count} μέρα', '{count} μέρες'],
59+
'hour': ['{count} ώρα', '{count} ώρες'],
60+
'minute': ['{count} λεπτό', '{count} λεπτά'],
61+
'second': ['{count} δευτερόλεπτο', '{count} δευτερόλεπτα'],
6262

6363
# Relative time
6464
'ago': 'πρίν απο {time}',

pendulum/lang/en.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
},
5353

5454
# Units of time
55-
'year': ['1 year', '{count} years'],
56-
'month': ['1 month', '{count} months'],
57-
'week': ['1 week', '{count} weeks'],
58-
'day': ['1 day', '{count} days'],
59-
'hour': ['1 hour', '{count} hours'],
60-
'minute': ['1 minute', '{count} minutes'],
61-
'second': ['1 second', '{count} seconds'],
55+
'year': ['{count} year', '{count} years'],
56+
'month': ['{count} month', '{count} months'],
57+
'week': ['{count} week', '{count} weeks'],
58+
'day': ['{count} day', '{count} days'],
59+
'hour': ['{count} hour', '{count} hours'],
60+
'minute': ['{count} minute', '{count} minutes'],
61+
'second': ['{count} second', '{count} seconds'],
6262

6363
# Relative time
6464
'ago': '{time} ago',

pendulum/lang/eo.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
},
5353

5454
# Units of time
55-
'year': ['1 jaro', '{count} jaroj'],
56-
'month': ['1 monato', '{count} monatoj'],
57-
'week': ['1 semajno', '{count} semajnoj'],
58-
'day': ['1 tago', '{count} tagoj'],
59-
'hour': ['1 horo', '{count} horoj'],
60-
'minute': ['1 minuto', '{count} minutoj'],
61-
'second': ['1 sekundo', '{count} sekundoj'],
55+
'year': ['{count} jaro', '{count} jaroj'],
56+
'month': ['{count} monato', '{count} monatoj'],
57+
'week': ['{count} semajno', '{count} semajnoj'],
58+
'day': ['{count} tago', '{count} tagoj'],
59+
'hour': ['{count} horo', '{count} horoj'],
60+
'minute': ['{count} minuto', '{count} minutoj'],
61+
'second': ['{count} sekundo', '{count} sekundoj'],
6262

6363
# Relative time
6464
'ago': 'antaŭ {time}',

0 commit comments

Comments
 (0)