Comments (7)
python-dateutil 2.5.3 parses the above correctly.
However there's another issue with the day and month being swapped:
>>> from delorean import parse
>>> parse('2015-01-02').date
datetime.date(2015, 2, 1)
>>> parse('2015-01-13').date
datetime.date(2015, 1, 13)
Downgrading to 2.5.1 is a temporary workaround.
from delorean.
Looks like there is a bug with the dayfirst
argument to dateutil.parser.parse
.
In python-dateutil 2.5.1:
>>> from dateutil.parser import parse
>>> parse('2015-01-02')
datetime.datetime(2015, 1, 2, 0, 0)
>>> parse('2015-01-02', dayfirst=True)
datetime.datetime(2015, 1, 2, 0, 0)
In python-dateutil 2.5.3:
>>> from dateutil.parser import parse
>>> parse('2015-01-02')
datetime.datetime(2015, 1, 2, 0, 0)
>>> parse('2015-01-02', dayfirst=True)
datetime.datetime(2015, 2, 1, 0, 0)
dateutil bug: dateutil/dateutil#233 (comment)
from delorean.
In the latest version of dateutil
(2.5.3) with dayfirst=True
and yearfirst=True
(the delorean
defaults), XXXX-XX-XX
will be parsed as YYYY-DD-MM
(unless the last part is > 12
where it will be parsed as YYYY-MM-DD
).
Might want to consider defaulting dayfirst=False
so ISO 8601 dates are handled correctly.
from delorean.
@rupert any chance you want to make this switch add tests and update documentation?
from delorean.
Unfortunately I don't think you can handle ISO 8601 dates and something like DD/MM/YYYY
(sensible default rather than MM/DD/YYYY
) with the same datefirst
argument in dateutil
2.5.3.
dayfirst=False
parses ISO 8601 dates correctly but of course parses DD/MM/YYYY
as MM/DD/YYYY
:
>>> parse('2003-02-01', dayfirst=False)
datetime.datetime(2003, 2, 1, 0, 0)
>>> parse('01/02/2003', dayfirst=False) # wrong
datetime.datetime(2003, 1, 2, 0, 0)
dayfirst=True
parses DD/MM/YYYY
correctly but not ISO 8601 dates:
>>> parse('2003-02-01', dayfirst=True) # wrong
datetime.datetime(2003, 1, 2, 0, 0)
>>> parse('01/02/2003', dayfirst=True)
datetime.datetime(2003, 2, 1, 0, 0)
Possibly you could attempt to parse the date with the iso8601
library first and fallback to dateutil
with dayfirst=True
if that fails.
As an aside I'm actually not using delorean
for parsing anymore as I think it's better to be explicit about which formats your program will accept.
This is a duplicate of #84.
from delorean.
Another option is pinning dateutil
to <=2.5.1
and waiting for the new parsing interface in 2.6.
See this comment: dateutil/dateutil#229 (comment)
from delorean.
@rupert dateutil2.6 has been released as @gordol pointed out. Mine checking to see if it fixes the issues you name above?
from delorean.
Related Issues (20)
- Pip package is not updated HOT 2
- parse function does not parse date string correctly
- Publish New Version HOT 5
- Language support HOT 1
- Fix simple typo: specificed -> specified
- mistake in parse example HOT 1
- zoneinfo.ZoneInfo AttributeError while parsing within the Django context HOT 1
- mock requirement could be optional
- PytzUsageWarning "normalize method is no longer necessary" when using delorean.parse()
- #118
- Issue with tzlocal==5.0
- Fix midnight() and naive() references on Quickstart page HOT 2
- Strict ISO 8601 parser HOT 1
- Add a wrapper for babel's parse_pattern() HOT 2
- Delorean.now() accepts timezone while delorean.now() does not
- parser failling in RFC3339 format HOT 1
- delorean.dates.UTC is gone in 0.6.0
- Some kind of time delta for localized "business days"
- Delorean.shift does not take datetime.timezone.utc HOT 3
- stops() skips february??? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from delorean.