Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Convert date/datetime strings to Python date/datetime

See original GitHub issue

One 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:

Something like this could be done at getattr time in AttrDict, updating the _d object on the fly on first access.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

honzakralcommented, Nov 13, 2017

@barseghyanartur: this is already done for you when you define your mapping in python via the DocType class

barseghyanarturcommented, Nov 13, 2017


from dateutil import parser

And we get or datetime.datetime objects.

Read more comments on GitHub >

github_iconTop 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 -
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found