Closed rdbisme closed 8 years ago
@cmlenz hey, do you happen to remember why you put this in there? Thanks!
No, I don't remember the reason. If there's no problem with parsing the microsecond part, it really shouldn't be stripped out. Note that the inverse _to_json
is also stripping them out, so that would need to be changed, too.
@rubendibattista there's your answer! Do you want to contribute a fix for this?
@cmlenz thanks for the quick response.
Ok. Thanks to both of you. I will start working on that.
Let me guess: because compatibility with else systems which expects datetime in %Y-%m-%d %H:%M:%S
format and may be surprised by microseconds? Like JavaScript's Date.parse()
.
@kxepal So what then? We could add something like an optional argument (that defaults to "no microseconds") to allow the user to specify if he needs microseconds... What do you suggest?
@rubendibattista mmm....probably just store such datetimes as timestamps with microsecond resolution? Like
>>> dt = datetime.datetime.now()
>>> ts = int(dt.timestamp() * 10**6)
>>> ts
1465330452610979
>>> doc.timestamp = ts
Well, I would prefer the ISO standard here with microseconds support instead of plain timestamp. It's easier when you look at it inside the database.
Hello, for the purpose I'm using CouchDB and this library I would need the microseconds too in the
DateTime
field of a document. Why are you stripping them out?https://github.com/djc/couchdb-python/blob/master/couchdb/mapping.py#L490