dered by those example :)
So are 2019-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 featu
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
t
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 time
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 takes
loops, best of 3: 11.2 usec 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.g
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, 10
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 t
.datetime(**i[-1]))
> return l
>
> # example
> if __name__ == '__main__':
> tests = ['04/12/2018',
> '04/12/2018 3:2:1',
> '2018-03-4 09:7:4',
> '2018-03-04T09:7:4.645194',
&g
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:
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 time
]))
return l
# example
if __name__ == '__main__':
tests = ['04/12/2018',
'04/12/2018 3:2:1',
'2018-03-4 09:7:4',
'2018-03-04T09:7:4.645194',
'20180304121940.948000Z']
for i in tests:
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 no
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/datep
13 matches
Mail list logo