isodate

isodate.duration.Duration: Duration comparison is inconsistent?

◇◆丶佛笑我妖孽 提交于 2019-12-24 21:05:51
问题 This is copied straight out of my console: >>> import isodate >>> import datetime First statements are as expected. 1 month duration not longer than 10 years duration. >>> duration = isodate.parse_duration("P1M") >>> duration > isodate.duration.Duration(0, 0, 0, years=10, months=0) False But then I get 1 month duration is longer than 10 years duration all of a sudden. >>> duration = isodate.parse_duration("P1M") >>> isinstance(duration, isodate.Duration) True >>> duration > isodate.duration

moment.js timezone inconsistency

淺唱寂寞╮ 提交于 2019-12-24 16:31:16
问题 I am formatting a given date using momentjs. The following behaves differently in different timezones: moment(new Date("2016" + "-" + "06" + "-01").toISOString()).format('MMMM YYYY') It gives me May 2016 in timezone of America/Denver and June 2016 in Asia/Karachi. I tested by changing the browser timezone to different timezones. It should be June 2016 in both. When i change the format in new Date() to use slashes instead of hyphens like below, it gives me correct result in both timezones i.e.

restkit and iso date

风流意气都作罢 提交于 2019-12-24 11:14:24
问题 I'm having trouble parsing an iso date from my json api/mongodb using rest kit. The iso date string I'm getting back is "2011-11-15T04:00:00Z" whichdoesn't get converted to an nsdate in my object, showing as null. What's the recommended work around if I can't format my date string, server side at the api? 回答1: Saw this post in google groups http://groups.google.com/group/restkit/browse_thread/thread/5ffaa4626209881 Looks like you would have to create your own date formatter and add it to the

importing CSV file MongoDB with ISODate

前提是你 提交于 2019-12-23 21:38:03
问题 When I export my data from mongoDB I obtain the following file: Everything is a string in the mongoDB except for the date that is ISODate. 123@123.com,sha1:64000:18:BTJnM903gIt5FNlSsZIRx1tLC9ErPJuB:9YVs800sgRPr1aaLj73qqnJ6,123,123,123@123.com,2017-04-28T09:20:07.480Z,cus_AYcVXIUf68nT52 If I import this file into MongoDB it import each value as String value. I need to parse the date as Date format, the rest can be string. I've seen that there's an argument for MongoImport --columnsHaveTypes. I

mongodb ISODate problems

◇◆丶佛笑我妖孽 提交于 2019-12-21 20:18:00
问题 I am using java(IDE is eclipse) to query on mongodb. Below is my java code: DBObject query = new BasicDBObject(); ObjectId id =new ObjectId("529f280b90ee58cb7732c2b8"); query.put("_id", id); DBCursor cursor = collection.find(query); while(cursor.hasNext()) { DBObject object = (DBObject)(cursor.next()); System.out.println(object.get("_id")); System.out.println(object.get("createDate")); } Problems happened in the createDate whose type is ISODate and value is ISODate("2013-10-21T01:34:04.808Z")

ISO 8601 Date JS Interpretation Difference - IE/FF versus Chrome

穿精又带淫゛_ 提交于 2019-12-19 10:16:55
问题 Why do IE/FF and Chrome javascript engines differ on how to interpret this Date format ( YYYY-MM-DDTHH:mm:ss.fff ) without the timezone designator? new Date("2015-02-18T15:43:57.803").getUTCHours() UTC Hours Chrome: 15 IE11/FF: 21 I don't understand this - is it because Chrome assumes it's local whereas IE/FF assume it's UTC? This seems like a Chrome bug. Interestingly - appending a "Z" to the end of the string tells both Chrome and IE/FF that the time is UTC and they can agree. Has anyone

Difference between “now” and a given date

最后都变了- 提交于 2019-12-12 21:03:24
问题 I need to retrieve all documents in a collection that the difference between new ISODate() and a date field of the document should be greater than a given parameter. I can do this on mongo shell by the query: db.getCollection('tb_registered_app').aggregate( [ { $project: { difference: { $subtract: [ new ISODate(), "$ping_date" ] } } } , { $match: {difference: { "$gte": 300000}} } ] ) I'm trying to use Spring Data MongoDB to execute the same query, with the code: public List<RegisteredApp>

Nanoseconds lost coming from MongoDB ISODate Object

北慕城南 提交于 2019-12-12 20:55:41
问题 I'm losing the nanoseconds from the MongoDb interface for the ISODate object. All the nanoseconds are set to zero when I read them in perl. First, my environment: MongoDB version: 1.8.2 perl v5.12.4 MongoDB perl module version: 0.701.4 I have a Mongo DB that has rtcTime coded as an ISODate, as follows: "rtcTime" : ISODate("2013-05-13T18:54:55.918Z") The code to extract the rtcTime looks something like this: my @results = $db->get_collection( 'timings' )->find( )->all(); foreach my $record (

Node + Mongodb + ISODate + Timezone issue

笑着哭i 提交于 2019-12-12 04:25:44
问题 Hello I am working in node js + mongodb. When I insert the data into collection the data is stored default ISODate eg. ISODate("2016-06-17T13:00:21.665Z") I want to insert the date fields should be store in UTC. Its already stored in UTC format or need to change anything in code ? Please anyone suggest me. My Code: var query = {}; query.created_by = 'admin'; query.created_on = new Date(); var collection = mongoUtil.list; collection.insert(query, function(err, item) { if (!err && item) {

How to create negative datetime in python 2.7

戏子无情 提交于 2019-12-11 11:08:50
问题 I need to insert into mongo db some BC dates but I cant create datetime with negative value like datetime.datetime(-2000, 2, 1) , but in mongodb it is possible to do with IsoDate, so how can i create negative dates in python? I'm currently using python 2.7, and i do it on purpouse, for the project. 回答1: Python 2.7's datetime library can only handle AD dates. If you need to go back further than that you will have to look at other libraries such as the Time class in Astropy or date in datautil.