Skip to content

Commit 5066d74

Browse files
committed
Merge branch 'master' into develop
2 parents 8dc70c0 + 06b0085 commit 5066d74

File tree

13 files changed

+96
-15
lines changed

13 files changed

+96
-15
lines changed

CHANGELOG.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22

3-
[Unreleased]
3+
## [1.1.1] - 2017-03-14
4+
5+
### Fixed
6+
7+
- Fixed `diff_for_humans()` when crossing DST transitions.
8+
9+
10+
## [1.1.0] - 2017-02-20
411

512
### Added
613

@@ -13,7 +20,7 @@
1320
- Formatting (with f-strings or `format()`) will now use the configured formatter.
1421

1522

16-
## [1.0.2]
23+
## [1.0.2] - 2017-02-04
1724

1825
### Changed
1926

@@ -24,14 +31,14 @@
2431
- Fixed `day_of_year` not returning the correct value. (Thanks to [asrenzo](https://github.com/asrenzo))
2532

2633

27-
## [1.0.1]
34+
## [1.0.1] - 2017-01-25
2835

2936
### Fixed
3037

3138
- Fixed parsing, especially for strings in the form `31-01-01`.
3239

3340

34-
## [1.0.0]
41+
## [1.0.0] - 2017-01-17
3542

3643
### Changed
3744

@@ -333,7 +340,9 @@ Initial release
333340

334341

335342

336-
[Unreleased]: https://github.com/sdispater/pendulum/compare/1.0.2...develop
343+
[Unreleased]: https://github.com/sdispater/pendulum/compare/1.1.1...master
344+
[1.1.1]: https://github.com/sdispater/pendulum/releases/tag/1.1.1
345+
[1.1.0]: https://github.com/sdispater/pendulum/releases/tag/1.1.0
337346
[1.0.2]: https://github.com/sdispater/pendulum/releases/tag/1.0.2
338347
[1.0.1]: https://github.com/sdispater/pendulum/releases/tag/1.0.1
339348
[1.0.0]: https://github.com/sdispater/pendulum/releases/tag/1.0.0

docs/_docs/instantiation.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,14 @@ You can also instantiate ``Pendulum`` instances by passing a string to the ``par
140140
print(dt)
141141
'1975-05-21T22:00:00+00:00
142142
143-
The library natively supports the RFC 3339 format, most ISO 8601 formats and some other common formats. If you pass a non-standard or more complicated
144-
string, the library will fallback on the `dateutil <https://dateutil.readthedocs.io>`_ parser.
143+
# You can pass a tz keyword to specify the timezone
144+
dt = pendulum.parse('1975-05-21 22:00:00', tz='Europe/Paris')
145+
print(dt)
146+
'1975-05-21T22:00:00+01:00'
147+
148+
The library natively supports the RFC 3339 format, most ISO 8601 formats and some other common formats.
149+
If you pass a non-standard or more complicated string, the library will fallback on the
150+
`dateutil <https://dateutil.readthedocs.io>`_ parser.
145151

146152
RFC 3339
147153
~~~~~~~~

docs/_docs/period.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,42 @@ instances that generated it, so that it can give access to more methods and prop
3737
3838
# Note that the weeks property
3939
# will change compared to the Interval class
40-
period.weeks = 2 # 832 for the interval
40+
period.weeks
41+
2 # 832 for the interval
4142
4243
# However the days property will still remain the same
4344
# to keep the compatiblity with the timedelta class
4445
period.days
4546
5829
4647
48+
Be aware that a period, just like an interval, is compatible with the ``timedelta`` class regarding
49+
its attributes. However, its custom attributes (like ``remaining_days``) will be aware of any DST
50+
transitions that might have occurred and adjust accordingly. Let's take an example:
51+
52+
.. code-block:: python
53+
54+
import pendulum
55+
56+
start = pendulum.create(2017, 3, 7, tz='America/Toronto')
57+
end = start.add(days=6)
58+
59+
period = end - start
60+
61+
# timedelta properties
62+
period.days
63+
5
64+
period.seconds
65+
82800
66+
67+
# period properties
68+
period.remaining_days
69+
6
70+
period.hours
71+
0
72+
period.remaining_seconds
73+
0
74+
75+
4776
.. warning::
4877

4978
Due to its nature (fixed duration between two datetimes), most arithmetic operations will

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
# built documents.
5959
#
6060
# The short X.Y version.
61-
version = '1.0'
61+
version = '1.1'
6262
# The full version, including alpha/beta/rc tags.
63-
release = '1.0.2'
63+
release = '1.1.1'
6464

6565
# The language for content autogenerated by Sphinx. Refer to documentation
6666
# for a list of supported languages.
File renamed without changes.

docs/index.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
.. toctree::
2+
:hidden:
3+
:maxdepth: 2
4+
5+
index
6+
date/index
7+
time/index
8+
19
.. include:: _docs/installation.rst
210
.. include:: _docs/introduction.rst
311
.. include:: _docs/instantiation.rst
@@ -14,5 +22,3 @@
1422
.. include:: _docs/interval.rst
1523
.. include:: _docs/period.rst
1624
.. include:: _docs/limitations.rst
17-
.. include:: _docs/date.rst
18-
.. include:: _docs/time.rst
File renamed without changes.

pendulum/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
22

3+
from .parsing.exceptions import ParserError
4+
35

46
class PendulumException(BaseException):
57

pendulum/formatting/difference_formatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def diff_for_humans(self, date, other=None, absolute=False, locale=None):
6363

6464
if diff.remaining_days > 3:
6565
count += 1
66-
elif diff.days > 0:
66+
elif diff.remaining_days > 0:
6767
unit = 'day'
68-
count = diff.days
68+
count = diff.remaining_days
6969
elif diff.hours > 0:
7070
unit = 'hour'
7171
count = diff.hours

pendulum/period.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ def days(self):
9999
def remaining_days(self):
100100
return abs(self._delta['days']) % 7 * self._sign(self._days)
101101

102+
@property
103+
def hours(self):
104+
return self._delta['hours']
105+
106+
@property
107+
def minutes(self):
108+
return self._delta['minutes']
109+
102110
@property
103111
def start(self):
104112
return self._start

0 commit comments

Comments
 (0)