Skip to content

Commit 694b140

Browse files
committed
Merge branch 'develop'
2 parents 95fd48e + 6d8e926 commit 694b140

File tree

101 files changed

+8444
-2392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+8444
-2392
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ matrix:
2222
env: PENDULUM_EXTENSIONS=1
2323
- python: 3.5
2424
env: PENDULUM_EXTENSIONS=0
25+
- python: 3.6-dev
26+
env: PENDULUM_EXTENSIONS=1
27+
- python: 3.6-dev
28+
env: PENDULUM_EXTENSIONS=0
2529
- python: pypy
2630

2731
before_install:

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# Change Log
22

3+
## [Unreleased]
4+
5+
### Added
6+
7+
- Added a `Date` class.
8+
- Added a `Time` class.
9+
- Added experimental support for the `fold` attribute introduced in Python 3.6.
10+
- Added a `remaining_days` property to the `Interval` class.
11+
- Added a `int_timestamp` property to the `Pendulum` class to retrieve the behavior of the now deprecated `timestamp` property.
12+
- `start_of()`/`end_of()` now supports `hour`, `minute` and `second` units.
13+
- `astimezone()` now supports timezone strings.
14+
- `in_words()` now displays subseconds when no other units are available.
15+
16+
### Changed
17+
18+
- `Period` properties (especially `years` and `months`) are now accurate.
19+
- `Interval.seconds` now returns the whole number of remaining seconds, like `timedelta`, for compatibility. Use `remaining_seconds` to retrieve the previous behavior.
20+
- Improved parsing performances for common formats.
21+
- The library no longer relies on `pytz`. It now depends on [pytzdata](https://github.com/sdispater/pytzdata) for its timezone database.
22+
- Locale, test instance and formatter are now set gobally at the module level when using the corresponding module methods.
23+
24+
### Deprecated
25+
26+
- `timestamp` should now be used as a method and no longer as a property. It will be a native method in the next major version.
27+
- `Interval` properties and methods related to years and months are now deprecated.
28+
- `Interval.days_exclude_weeks` is now deprecated. Use `remaining_days` instead.
29+
30+
### Fixed
31+
32+
- Exception when loading specific timezones has been fixed.
33+
- `end_of('day')` now properly sets microseconds to `999999`.
34+
- Accuracy of `Period` instances properties has been improved.
35+
- Accuracy for microseconds when initializing a Pendulum instance in some timezones has been fixed.
36+
- Periods are now serializable with `pickle`.
37+
- Fixed `minute_()`, `second_()` and `microsecond_()` setters changing the hour unit.
38+
- Fixed Windows support.
39+
40+
341
## [0.6.6] - 2016-11-25
442

543
### Fixed
@@ -234,6 +272,7 @@ This version causes major breaking API changes to simplify it and making it more
234272
Initial release
235273

236274

275+
[Unreleased]: https://github.com/sdispater/pendulum/compare/master...develop
237276
[0.6.6]: https://github.com/sdispater/pendulum/releases/tag/0.6.6
238277
[0.6.5]: https://github.com/sdispater/pendulum/releases/tag/0.6.5
239278
[0.6.4]: https://github.com/sdispater/pendulum/releases/tag/0.6.4

appveyor.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
build: false
2+
3+
environment:
4+
matrix:
5+
- PYTHON: "C:/Python27"
6+
- PYTHON: "C:/Python27-x64"
7+
- PYTHON: "C:/Python33"
8+
- PYTHON: "C:/Python33-x64"
9+
- PYTHON: "C:/Python34"
10+
- PYTHON: "C:/Python34-x64"
11+
- PYTHON: "C:/Python35"
12+
- PYTHON: "C:/Python35-x64"
13+
14+
install:
15+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
16+
17+
# Upgrade to the latest version of pip to avoid it displaying warnings
18+
# about it being out of date.
19+
- "pip install --disable-pip-version-check --user --upgrade pip"
20+
21+
# Install dependencies
22+
- "%CMD_IN_ENV% pip install -r tests-requirements.txt"
23+
- "%CMD_IN_ENV% pip install codecov"
24+
25+
test_script:
26+
- "py.test --cov=pendulum --cov-config=.coveragerc tests/"
27+
28+
after_test:
29+
- "codecov"

docs/_docs/addition_subtraction.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
Addition and Subtraction
2+
========================
3+
4+
To easily adding and subtracting time, you can use the ``add()`` and ``subtract()``
5+
methods.
6+
Each method returns a new ``Pendulum`` instance.
7+
8+
.. code-block:: python
9+
10+
import pendulum
11+
12+
dt = pendulum.create(2012, 1, 31, 0)
13+
14+
dt.to_datetime_string()
15+
'2012-01-31 00:00:00'
16+
17+
dt = dt.add(years=5)
18+
'2017-01-31 00:00:00'
19+
dt = dt.add(years=1)
20+
'2018-01-31 00:00:00'
21+
dt = dt.subtract(years=1)
22+
'2017-01-31 00:00:00'
23+
dt = dt.subtract(years=5)
24+
'2012-01-31 00:00:00'
25+
26+
dt = dt.add(months=60)
27+
'2017-01-31 00:00:00'
28+
dt = dt.add(months=1)
29+
'2017-02-28 00:00:00'
30+
dt = dt.subtract(months=1)
31+
'2017-01-28 00:00:00'
32+
dt = dt.subtract(months=60)
33+
'2012-01-28 00:00:00'
34+
35+
dt = dt.add(days=29)
36+
'2012-02-26 00:00:00'
37+
dt = dt.add(days=1)
38+
'2012-02-27 00:00:00'
39+
dt = dt.subtract(days=1)
40+
'2012-02-26 00:00:00'
41+
dt = dt.subtract(days=29)
42+
'2012-01-28 00:00:00'
43+
44+
dt = dt.add(weeks=3)
45+
'2012-02-18 00:00:00'
46+
dt = dt.add(weeks=1)
47+
'2012-02-25 00:00:00'
48+
dt = dt.subtract(weeks=1)
49+
'2012-02-18 00:00:00'
50+
dt = dt.subtract(weeks=3)
51+
'2012-01-28 00:00:00'
52+
53+
dt = dt.add(hours=24)
54+
'2012-01-29 00:00:00'
55+
dt = dt.add(hours=1)
56+
'2012-02-25 01:00:00'
57+
dt = dt.subtract(hours=1)
58+
'2012-02-29 00:00:00'
59+
dt = dt.subtract(hours=24)
60+
'2012-01-28 00:00:00'
61+
62+
dt = dt.add(minutes=61)
63+
'2012-01-28 01:01:00'
64+
dt = dt.add(minutes=1)
65+
'2012-01-28 01:02:00'
66+
dt = dt.subtract(minutes=1)
67+
'2012-01-28 01:01:00'
68+
dt = dt.subtract(minutes=24)
69+
'2012-01-28 00:00:00'
70+
71+
dt = dt.add(seconds=61)
72+
'2012-01-28 00:01:01'
73+
dt = dt.add(seconds=1)
74+
'2012-01-28 00:01:02'
75+
dt = dt.subtract(seconds=1)
76+
'2012-01-28 00:01:01'
77+
dt = dt.subtract(seconds=61)
78+
'2012-01-28 00:00:00'
79+
80+
dt = dt.add(years=3, months=2, days=6, hours=12, minutes=31, seconds=43)
81+
'2015-04-03 12:31:43'
82+
dt = dt.subtract(years=3, months=2, days=6, hours=12, minutes=31, seconds=43)
83+
'2012-01-28 00:00:00'
84+
85+
# You can also add or remove a timedelta
86+
dt.add_timedelta(timedelta(hours=3, minutes=4, seconds=5))
87+
'2012-01-28 03:04:05'
88+
dt.sub_timedelta(timedelta(hours=3, minutes=4, seconds=5))
89+
'2012-01-28 00:00:00'
90+
91+
.. note::
92+
93+
Passing negative values to ``add()`` is also possible and will act exactly
94+
like ``subtract()``

docs/_docs/attributes_properties.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
Attributes and Properties
2+
=========================
3+
4+
Pendulum gives access to more attributes and properties than the default ``datetime`` class.
5+
6+
.. code-block:: python
7+
8+
import pendulum
9+
10+
dt = pendulum.parse('2012-9-5 23:26:11.123789')
11+
12+
# These properties specifically return integers
13+
dt.year
14+
2012
15+
dt.month
16+
9
17+
dt.day
18+
5
19+
dt.hour
20+
23
21+
dt.minute
22+
26
23+
dt.second
24+
11
25+
dt.microsecond
26+
123789
27+
dt.day_of_week
28+
3
29+
dt.day_of_year
30+
248
31+
dt.week_of_month
32+
1
33+
dt.week_of_year
34+
36
35+
dt.days_in_month
36+
30
37+
dt.timestamp()
38+
1346887571.123789
39+
dt.float_timestamp
40+
1346887571.123789
41+
dt.int_timestamp
42+
1346887571
43+
44+
pendulum.from_date(1975, 5, 21).age
45+
41 # calculated vs now in the same tz
46+
dt.quarter
47+
3
48+
49+
# Returns an int of seconds difference from UTC (+/- sign included)
50+
pendulum.from_timestamp(0).offset
51+
0
52+
pendulum.from_timestamp(0, 'America/Toronto').offset
53+
-18000
54+
55+
# Returns a float of hours difference from UTC (+/- sign included)
56+
pendulum.from_timestamp(0, 'America/Toronto').offset_hours
57+
-5.0
58+
pendulum.from_timestamp(0, 'Australia/Adelaide').offset_hours
59+
9.5
60+
61+
# Indicates if day light savings time is on
62+
pendulum.from_date(2012, 1, 1, 'America/Toronto').is_dst
63+
False
64+
pendulum.from_date(2012, 9, 1, 'America/Toronto').is_dst
65+
True
66+
67+
# Indicates if the instance is in the same timezone as the local timezone
68+
pendulum.now().local
69+
True
70+
pendulum.now('Europe/London').local
71+
False
72+
73+
# Indicates if the instance is in the UTC timezone
74+
pendulum.now().utc
75+
False
76+
pendulum.now('Europe/London').local
77+
False
78+
pendulum.utcnow().utc
79+
True
80+
81+
# Gets the timezone instance
82+
pendulum.now().timezone
83+
pendulum.now().tz
84+
85+
# Gets the timezone name
86+
pendulum.now().timezone_name

0 commit comments

Comments
 (0)