summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgweis <gerhard.weis@gmail.com>2017-07-05 04:06:13 (GMT)
committerGitHub <noreply@github.com>2017-07-05 04:06:13 (GMT)
commitb1b43bbb0240e7f2a5ad1d0b3f09e24a37f74b24 (patch)
treeb6d2f8655e8c7b811c2e159a9fc58689fd8ea7f9
parentf3888ca26cba70e8e2d44a817a1a7b53a33267ce (diff)
parent91f15b25b72085866482a61f39d6d1a3e8569691 (diff)
downloadisodate-b1b43bbb0240e7f2a5ad1d0b3f09e24a37f74b24.tar.gz
Merge pull request #36 from zsong/master
Fixed the issues #33
-rw-r--r--src/isodate/duration.py5
-rw-r--r--src/isodate/tests/test_duration.py4
2 files changed, 8 insertions, 1 deletions
diff --git a/src/isodate/duration.py b/src/isodate/duration.py
index 5408315..a215aa0 100644
--- a/src/isodate/duration.py
+++ b/src/isodate/duration.py
@@ -121,7 +121,10 @@ class Duration(object):
if self.years:
params.append('%d years' % self.years)
if self.months:
- params.append('%d months' % self.months)
+ fmt = "%d months"
+ if self.months <= 1:
+ fmt = "%d month"
+ params.append(fmt % self.months)
params.append(str(self.tdelta))
return ', '.join(params)
diff --git a/src/isodate/tests/test_duration.py b/src/isodate/tests/test_duration.py
index 0b80a54..d34902b 100644
--- a/src/isodate/tests/test_duration.py
+++ b/src/isodate/tests/test_duration.py
@@ -313,6 +313,10 @@ class DurationTest(unittest.TestCase):
self.assertEqual('10 years, 10 months, 10 days, 0:00:10', str(dur))
self.assertEqual('isodate.duration.Duration(10, 10, 0,'
' years=10, months=10)', repr(dur))
+ dur = Duration(months=0)
+ self.assertEqual('0:00:00', str(dur))
+ dur = Duration(months=1)
+ self.assertEqual('1 month, 0:00:00', str(dur))
def test_hash(self):
'''