Re: django.utils.dateparse

2019-02-04 Thread Giuseppe De Marco
019-02-04 and 04/02/19. (Or is it 02/04/19?) > It Will depend by settings.py, that's the goal > > Anyway, if you think this is generally useful, you can easily package it > into a third-party module. > Consider It done, I thougth on a wider featureset in Django.utils.dateparse >&g

Re: django.utils.dateparse

2019-02-04 Thread Aymeric Augustin
Hello Guiseppe, At this point I think we can agree on why we disagree :-) First, I believe that the function responsible for converting datetimes stored in ISO 8601 format in SQLite databases should parse ISO 8601 and not do anything else. I'm -1 on changing it to accept localized datetimes. (A

Re: django.utils.dateparse

2019-02-04 Thread Giuseppe De Marco
Thank you Andreas, finally I can see a real benchmark on my laptop: python3 -m timeit -s "from django.utils.dateparse import parse_datetime" "print(parse_datetime('2018-04-01 09:07:04'))" 10 loops, best of 3: 11.1 usec per loop python3 -m timeit -s &quo

Re: django.utils.dateparse

2019-02-04 Thread Andreas Pelme
On 4 Feb 2019, at 15:04, Giuseppe De Marco wrote: > > python3 -m timeit -s "import sys, os; sys.path.append(os.getcwd()); from > datetime_heuristic_parser import datetime_heuristic_parser; > print(datetime_heuristic_parser('04/12/2018 09:7:4Z'))" That command is not correct. timeit -s

Re: django.utils.dateparse

2019-02-04 Thread Giuseppe De Marco
ec per loop python3 -m timeit -s "from django.utils.dateparse import parse_datetime" "parse_datetime('2019-02-03T17:27:58.645194')" 10 loops, best of 3: 6.04 usec per loop python3 -m timeit -s "import sys, os; sys.path.append(os.getcwd()); from datetime_heuristic_p

Re: django.utils.dateparse

2019-02-04 Thread Tom Forbes
For me, I get: In [4]: %timeit datetime_heuristic_parser('2019-02-03T17:27:58.645194') 18.9 µs ± 431 ns per loop (mean ± std. dev. of 7 runs, 10 loops each) And for Django: In [3]: %timeit parse_datetime('2019-02-03T17:27:58.645194') 6.97 µs ± 408 ns per loop (mean ± std. dev. of 7 runs,

Re: django.utils.dateparse

2019-02-04 Thread Giuseppe De Marco
Hello everyone, first of all I am grateful for your time and your attention. @Tom Forbes The first time I runned it I thought the same thing! Please use https://github.com/peppelinux/Django-snippets/blob/master/datetime_heuristic_parser.py and not the previous pasted one. I'm quite sure that all

Re: django.utils.dateparse

2019-02-03 Thread Aymeric Augustin
'20180304121940.948000Z'] > > for i in tests: > res = dateformat_insp(i) or datetimeformat_insp(i) > if res: > print('Parsing succesfull on "{}": {}'.format(i, res)) > #print(datetime_euristic_parser(i)) >

Re: django.utils.dateparse

2019-02-03 Thread Tom Forbes
I’m pretty sure 0.0241 usec per loop is either a typo or a mistake during benchmarking. I’ve got no comment what you’re proposing but correct and valid benchmarks are important, so I would double check that. On 3 February 2019 at 23:37:14, Giuseppe De Marco ( giuseppe.dema...@unical.it) wrote:

Re: django.utils.dateparse

2019-02-03 Thread Giuseppe De Marco
Regarding the previous example, better to read it here (my fault: I mistaken the format '%Y-%m-%dT%H:%M:%S.%f'): https://github.com/peppelinux/Django-snippets/blob/master/datetime_heuristic_parser.py and also, it should came also with tzinfo regexp and other functions as well, like parse_date

Re: django.utils.dateparse

2019-02-03 Thread Giuseppe De Marco
= dateformat_insp(i) or datetimeformat_insp(i) if res: print('Parsing succesfull on "{}": {}'.format(i, res)) #print(datetime_euristic_parser(i)) else: print('Parsing failed on "{}"'.format(i)) print() I also checked these

Re: django.utils.dateparse

2019-02-03 Thread Aymeric Augustin
Hello Guiseppe, django.utils.dateparse provides helpers needed by Django to implement datetime, date and time fields on SQLite. (SQLite doesn't have a native date time type.) Their job is to parse ISO 8601 fast. That's it. A utility module should do exactly what Django needs and nothing more

django.utils.dateparse

2019-02-03 Thread Giuseppe De Marco
Hi All, it's the first time for me in this ml, I'd like to purpose a refactor of django.utils.dateparse functions. Currently a function in it, like parse_date for example, extract date time string with a static regexp... https://docs.djangoproject.com/pl/2.1/_modules/django/utils/dateparse