Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dates should stringify with 8601 format #496

Closed
jchris opened this issue Aug 21, 2015 · 1 comment
Closed

Dates should stringify with 8601 format #496

jchris opened this issue Aug 21, 2015 · 1 comment
Labels
Milestone

Comments

@jchris
Copy link

jchris commented Aug 21, 2015

I am fairly sure that when I do this:

properties["begin"] = new DateTime(session.start);

and then save, sync, and load the document, the string value of the "begin" field is something like

ios simulator screen shot aug 21 2015 3 36 03 pm

It should be formatted like this:

2012-04-23T18:25:43.511Z

@zgramana zgramana added the bug label Aug 21, 2015
@zgramana zgramana added this to the 1.2 milestone Aug 21, 2015
@borrrden
Copy link
Member

borrrden commented Sep 4, 2015

@jchris

I wrote a simple test for this and it passed:

var now = DateTime.UtcNow;
    var doc = new Dictionary<string, object> {
     { "begin", now }
};

// The following line resulted in {"begin":"2015-09-04T00:33:02.960719Z"}
 var json = Manager.GetObjectMapper().WriteValueAsString(doc); 

// Note that "now.ToString()" prints 9/4/2015 12:33:02 AM

I think what is going on here is that when you are putting the item into your list view, you are simply calling ToString() which results in the format you see in the screenshot (in other words, the default string representation of a DateTime object). You may also be using String.Format() or something that uses it internally. The DateTime object in question should be fully serialized back to a DateTime object and not a string anyway. Let me know a little more about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants