mirror of
https://github.com/kennethreitz/maya.git
synced 2026-06-05 14:50:19 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b016434b6f | |||
| bdf2bb332b | |||
| 6522525d7c | |||
| 3a83f10988 | |||
| 05eb0d0051 | |||
| 61eabc54e0 | |||
| 6bb380e7c5 |
@@ -1,3 +1,8 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
freezegun = "*"
|
||||
pytest = "*"
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ Art by `Sam Flores
|
||||
<https://www.instagram.com/samagram12/>`_ (Photo by `Kenneth Reitz
|
||||
<https://www.instagram.com/kennethreitz/>`_).
|
||||
|
||||
If you're interested in financially supporting Kenneth Reitz open source, consider `visiting this link <https://cash.me/$KennethReitz>`_. Your support helps tremendously with sustainability of motivation, as Open Source is no longer part of my day job.
|
||||
|
||||
☤ Basic Usage of Maya
|
||||
---------------------
|
||||
@@ -137,7 +138,7 @@ From here, there are a number of methods available to you, which you can use to
|
||||
☤ What about Delorean, Arrow, & Pendulum?
|
||||
-----------------------------------------
|
||||
|
||||
All these project complement each other, and are friends. Pendulum, for example, helps power Maya's parsing.
|
||||
All these projects complement each other, and are friends. Pendulum, for example, helps power Maya's parsing.
|
||||
|
||||
Arrow, for example, is a fantastic library, but isn't what I wanted in a datetime library. In many ways, it's better than Maya for certain things. In some ways, in my opinion, it's not.
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
__version__ = '0.5.0'
|
||||
__version__ = '0.6.0'
|
||||
|
||||
+5
-3
@@ -346,7 +346,6 @@ class MayaDT(object):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
dt.set_formatter("alternative")
|
||||
delta = humanize.time.abs_timedelta(
|
||||
timedelta(seconds=(self.epoch - now().epoch)))
|
||||
|
||||
@@ -497,7 +496,7 @@ class MayaInterval(object):
|
||||
|
||||
try:
|
||||
end = parse(end)
|
||||
except pendulum.parsing.exceptions.ParserError as e:
|
||||
except (pendulum.parsing.exceptions.ParserError, TypeError) as e:
|
||||
end = cls.parse_iso8601_duration(end, start=start)
|
||||
|
||||
return cls(start=start, end=end)
|
||||
@@ -740,7 +739,7 @@ def when(string, timezone='UTC', prefer_dates_from='current_period'):
|
||||
return MayaDT.from_datetime(dt)
|
||||
|
||||
|
||||
def parse(string, timezone='UTC', day_first=False, year_first=True):
|
||||
def parse(string, timezone='UTC', day_first=False, year_first=True, strict=False):
|
||||
""""Returns a MayaDT instance for the machine-produced moment specified.
|
||||
|
||||
Powered by pendulum.
|
||||
@@ -755,11 +754,14 @@ def parse(string, timezone='UTC', day_first=False, year_first=True):
|
||||
between YDM and YMD. (default: False)
|
||||
year_first -- if true, the first value (e.g. 2016/05/01)
|
||||
is parsed as year (default: True)
|
||||
strict -- if False, allow pendulum to fall back on datetime parsing
|
||||
if pendulum's own parsing fails
|
||||
"""
|
||||
options = {}
|
||||
options['tz'] = timezone
|
||||
options['day_first'] = day_first
|
||||
options['year_first'] = year_first
|
||||
options['strict'] = strict
|
||||
|
||||
dt = pendulum.parse(str(string), **options)
|
||||
return MayaDT.from_datetime(dt)
|
||||
|
||||
Reference in New Issue
Block a user