Convert date/datetime strings to Python date/datetime
See original GitHub issueOne of the nice things from elasticutils was automatic conversion of date/datetime strings in responses to Python date/datetime objects. What are you thoughts on adding something like that here?
Here’s the code from elasticutils: https://github.com/mozilla/elasticutils/blob/master/elasticutils/__init__.py#L423-L437
Something like this could be done at getattr
time in AttrDict
, updating the _d
object on the fly on first access.
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
How To Convert a String to a datetime or time Object in Python
The Python datetime module includes the datetime.strptime() class method to convert a string to a datetime object. The Python time module ...
Read more >How to convert a string to a date in Python - Educative.io
Python provides the strptime() method, in its datetime class, to convert a string representation of the date/time into a date object.
Read more >python - Convert string "Jun 1 2005 1:33PM" into datetime
To obtain a date object using an existing datetime object, convert it using .date() : > ... strptime / strftime format string docs:...
Read more >How to Convert String to Datetime in Python - AppDividend
To convert a Python string to datetime, use the strptime() function. The strptime() function is available in datetime and time modules.
Read more >Converting Strings to datetime in Python - Stack Abuse
Python's datetime module can convert all different types of strings to a datetime object. But the main problem is that in order to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@barseghyanartur: this is already done for you when you define your mapping in python via the
DocType
class@HonzaKral:
And we get
datetime.date
ordatetime.datetime
objects.