Skip to content

Commit d3631c2

Browse files
committed
Merge branch 'master' into develop
2 parents 3ab45a0 + 1dfa24d commit d3631c2

25 files changed

+338
-58
lines changed

CHANGELOG.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
11
# Change Log
22

3-
## [Unreleased]
3+
## [1.2.5] - 2017-09-04
4+
5+
### Fixed
6+
7+
- Fixed normalization of microseconds in durations.
8+
- Fixed microseconds not being included in `average()`. (Thanks to [ericfrederich](https://github.com/ericfrederich))
9+
10+
11+
## [1.2.4] - 2017-06-20
12+
13+
### Fixed
14+
15+
- Fixed parsing of the `now` string.
16+
17+
18+
## [1.2.3] - 2017-06-18
19+
20+
### Fixed
21+
22+
- Fixed behavior of some short timezones (like EST, MST or HST).
23+
- Fixed warning when building C extensions.
24+
25+
26+
## [1.2.2] - 2017-06-15
27+
28+
### Fixed
29+
30+
- Fixed `next()` and `previous()` hanging when passed an invalid input.
31+
- Fixed wrong result when adding/subtracting a Period if a DST transition occurs.
32+
33+
34+
## [1.2.1] - 2017-05-23
35+
36+
### Fixed
37+
- Fixed incorrect `fold` attribute on Python 3.6 when not passing a timezone. (Thanks to [neonquill](https://github.com/neonquill))
38+
39+
40+
41+
## [1.2.0] - 2017-03-24
442

543
### Added
644

@@ -356,7 +394,13 @@ Initial release
356394

357395

358396

359-
[Unreleased]: https://github.com/sdispater/pendulum/compare/master...develop
397+
[Unreleased]: https://github.com/sdispater/pendulum/compare/1.2.5...master
398+
[1.2.5]: https://github.com/sdispater/pendulum/releases/tag/1.2.5
399+
[1.2.4]: https://github.com/sdispater/pendulum/releases/tag/1.2.4
400+
[1.2.3]: https://github.com/sdispater/pendulum/releases/tag/1.2.3
401+
[1.2.2]: https://github.com/sdispater/pendulum/releases/tag/1.2.2
402+
[1.2.1]: https://github.com/sdispater/pendulum/releases/tag/1.2.1
403+
[1.2.0]: https://github.com/sdispater/pendulum/releases/tag/1.2.0
360404
[1.1.1]: https://github.com/sdispater/pendulum/releases/tag/1.1.1
361405
[1.1.0]: https://github.com/sdispater/pendulum/releases/tag/1.1.0
362406
[1.0.2]: https://github.com/sdispater/pendulum/releases/tag/1.0.2

MANIFEST.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
include README.rst LICENSE
2-
recursive-exclude tests *
3-
recursive-exclude benchmark *
2+
exclude test*

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Pendulum
1010
.. image:: https://img.shields.io/codecov/c/github/sdispater/pendulum/master.svg
1111
:target: https://codecov.io/gh/sdispater/pendulum/branch/master
1212

13-
.. image:: https://travis-ci.org/sdispater/pendulum.png
13+
.. image:: https://travis-ci.org/sdispater/pendulum.svg
1414
:alt: Pendulum Build status
1515
:target: https://travis-ci.org/sdispater/pendulum
1616

docs/_docs/difference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ You may also pass ``True`` as a 2nd parameter to remove the modifiers `ago`, `fr
8383
# The most typical usage is for comments
8484
# The instance is the date the comment was created
8585
# and its being compared to default now()
86-
pendulum.now().subtract(dayss=1).diff_for_humans()
86+
pendulum.now().subtract(days=1).diff_for_humans()
8787
'5 days ago'
8888
8989
pendulum.now().diff_for_humans(Pendulum.now().subtract(years=1))

docs/_docs/instantiation.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ You'll notice above that the timezone (2nd) parameter was passed as a string and
1818
rather than a ``tzinfo`` instance. All timezone parameters have been augmented
1919
so you can pass a ``tzinfo`` instance, string or integer offset to GMT
2020
and the timezone will be created for you.
21+
22+
.. note::
23+
24+
Supported strings for timezones are the one provided by the `IANA time zone database <https://www.iana.org/time-zones>`_.
25+
The special ``local`` string is also supported and will return your current timezone.
26+
2127
This is again shown in the next example which also introduces the ``now()`` function.
2228

2329
.. code-block:: python
@@ -74,7 +80,7 @@ or simply a string timezone value.
7480

7581
.. code-block:: python
7682
77-
pendulum.from_format(time, format, tz)
83+
pendulum.from_format(time, fmt, tz)
7884
7985
``from_format()`` is mostly a wrapper for the base Python function ``datetime.strptime()``.
8086
The difference being the addition the ``tz`` argument that can be a ``tzinfo`` instance or a string timezone value

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.1'
61+
version = '1.2'
6262
# The full version, including alpha/beta/rc tags.
63-
release = '1.1.1'
63+
release = '1.2.5'
6464

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

pendulum/_compat.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@
44

55
PY2 = sys.version_info[0] == 2
66
PY3K = sys.version_info[0] >= 3
7-
PY33 = sys.version_info >= (3, 3)
87
PY36 = sys.version_info >= (3, 6)
98

109

11-
if PY2:
12-
long = long
13-
unicode = unicode
14-
basestring = basestring
15-
else:
10+
try: # Python 2
11+
long
12+
unicode
13+
basestring
14+
except NameError: # Python 3
1615
long = int
1716
unicode = str
1817
basestring = str
1918

20-
if PY33:
19+
try: # Python >= 3.3
2120
FileNotFoundError = FileNotFoundError
22-
else:
23-
FileNotFoundError = IOError # cf PEP-3151
21+
except NameError: # Python < 3.3
22+
FileNotFoundError = IOError # cf PEP-3151
2423

2524
def decode(string, encodings=None):
2625
if not PY2 and not isinstance(string, bytes):
@@ -29,8 +28,7 @@ def decode(string, encodings=None):
2928
if PY2 and isinstance(string, unicode):
3029
return string
3130

32-
if encodings is None:
33-
encodings = ['utf-8', 'latin1', 'ascii']
31+
encodings = encodings or ['utf-8', 'latin1', 'ascii']
3432

3533
for encoding in encodings:
3634
try:
@@ -48,8 +46,7 @@ def encode(string, encodings=None):
4846
if PY2 and isinstance(string, str):
4947
return string
5048

51-
if encodings is None:
52-
encodings = ['utf-8', 'latin1', 'ascii']
49+
encodings = encodings or ['utf-8', 'latin1', 'ascii']
5350

5451
for encoding in encodings:
5552
try:

pendulum/_extensions/_helpers.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ PyObject* parse_iso8601(PyObject *self, PyObject *args) {
426426
int separators = 0;
427427
int time = 0;
428428
int has_time = 0;
429-
int has_hour = 0;
430429
int has_offset = 0;
431430
int i;
432431
int j;
@@ -710,7 +709,6 @@ PyObject* parse_iso8601(PyObject *self, PyObject *args) {
710709
}
711710

712711
hour = time;
713-
has_hour = 1;
714712
break;
715713
case 4:
716714
// Hours and minutes
@@ -725,7 +723,6 @@ PyObject* parse_iso8601(PyObject *self, PyObject *args) {
725723

726724
hour = time / 100;
727725
minute = time % 100;
728-
has_hour = 1;
729726
break;
730727
case 6:
731728
// Hours, minutes and seconds
@@ -740,7 +737,6 @@ PyObject* parse_iso8601(PyObject *self, PyObject *args) {
740737
hour = time / 10000;
741738
minute = time / 100 % 100;
742739
second = time % 100;
743-
has_hour = 1;
744740
break;
745741
default:
746742
// Any other case is wrong

pendulum/date.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,9 @@ def next(self, day_of_week=None):
848848
if day_of_week is None:
849849
day_of_week = self.day_of_week
850850

851+
if day_of_week < SUNDAY or day_of_week > SATURDAY:
852+
raise ValueError('Invalid day of week')
853+
851854
dt = self.add(days=1)
852855
while dt.day_of_week != day_of_week:
853856
dt = dt.add(days=1)
@@ -869,6 +872,9 @@ def previous(self, day_of_week=None):
869872
if day_of_week is None:
870873
day_of_week = self.day_of_week
871874

875+
if day_of_week < SUNDAY or day_of_week > SATURDAY:
876+
raise ValueError('Invalid day of week')
877+
872878
dt = self.subtract(days=1)
873879
while dt.day_of_week != day_of_week:
874880
dt = dt.subtract(days=1)

pendulum/formatting/difference_formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def diff_for_humans(self, date, other=None, absolute=False, locale=None):
5555
unit = 'month'
5656
count = diff.months
5757

58-
if (diff.weeks * 7 + diff.remaining_days) > 28:
58+
if (diff.weeks * 7 + diff.remaining_days) >= 27:
5959
count += 1
6060
elif diff.weeks > 0:
6161
unit = 'week'

0 commit comments

Comments
 (0)