Skip to content

Commit 340f4bb

Browse files
committed
v.1.4.5 update
1 parent b0d1506 commit 340f4bb

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ By default datemath return an arrow date object representing your timestamp.
7676
<Arrow [2016-01-02T00:00:00+00:00]>
7777
>>> dm('now/d+2h+3m')
7878
<Arrow [2016-01-01T02:03:00+00:00]>
79-
>>>
79+
>>> dm('now+/d', roundDown=False)
80+
<Arrow [2016-01-01T23:59:00+00:00]>
81+
>>> dm('now/d')
82+
<Arrow [2016-01-01T00:00:00+00:00]>
8083
```
8184

8285
If you would rather have a string, you can use arrow's ```.format()``` method.
@@ -129,6 +132,15 @@ from datemath import dm
129132
```
130133

131134
# Release Notes
135+
* v1.4.5 - Added roundDown functionality. Allows user to specify the default rounding for expressions such as `/d`.
136+
* example - assuming the time is currently 2016-01-01 12:00:00, we should get the following
137+
```
138+
>>> dm('now+/d', roundDown=False)
139+
<Arrow [2016-01-01T23:59:00+00:00]>
140+
>>> dm('now/d')
141+
<Arrow [2016-01-01T00:00:00+00:00]>
142+
```
143+
* v1.4.4 - Fixed bug with expression logic and rounding: https://github.com/nickmaccarthy/python-datemath/pull/2
132144
* v1.4.3 - Floats are now supported for days, hours, and seconds units. Example ```now-2.5d```, ```now-3.2h```. Any other unit other than days, hours, or seconds that is a float will be converted to an int and floored due to the datetime() module not being able to handle them.
133145

134146
# Test

datemath/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from .helpers import parse
22

33
def dm(expr, **kwargs):
4+
''' does our datemath and returns an arrow object '''
45
return parse(expr, **kwargs)
56

67
def datemath(expr, **kwargs):
8+
''' does our datemath and returns a datetime object '''
79
return parse(expr, **kwargs).datetime

datemath/helpers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ def parse(expression, now=None, tz='UTC', type=None, roundDown=True):
8080
'''
8181
the main meat and potatoes of this this whole thing
8282
takes our datemath expression and does our date math
83+
:param expression - the datemath expression
84+
:param now - what time is now; when will now be then? soon
85+
:param type - if we are dealing with a arrow or datetime object
86+
:param roundDown - wether or not we should round up or round down on this. default is roundDown=True, which means if it was 12:00:00, `/d` would be '00:00:00', and with roundDown=False, `/d` would be '29:59:59'
8387
'''
8488
if now is None:
8589
now = arrow.utcnow()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
1717
long_description = f.read()
1818

19-
version = '1.4.4'
19+
version = '1.4.5'
2020

2121
setup(
2222
name='python-datemath',

0 commit comments

Comments
 (0)