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

String var containing time, not displayed correctly. #106

Closed
edvinv opened this issue May 7, 2015 · 6 comments · Fixed by #899
Closed

String var containing time, not displayed correctly. #106

edvinv opened this issue May 7, 2015 · 6 comments · Fixed by #899

Comments

@edvinv
Copy link

edvinv commented May 7, 2015

Variable time from following sample is in watch window displayed as: "05/07/2015 22:00:00", but of course logged to console correctly as "2015-05-07T22:00:00.000Z".

var time= "2015-05-07T22:00:00.000Z";
console.log(time);

@mousetraps mousetraps added this to the June milestone May 8, 2015
@mousetraps mousetraps modified the milestones: July, June Jun 15, 2015
@kant2002
Copy link
Contributor

Please correct me that this is should be done following way:

  1. Add test to the DebuggerTests.cs file
  2. Add file to the Nodejs\Tests\TestData\DebuggerProject\ where would be JS snippet above
  3. Run and make it green

@kant2002
Copy link
Contributor

Looks like I have test for that.
Now have more input how to fix that and what's broken.
The JToken object on the line https://github.com/Microsoft/nodejstools/blob/master/Nodejs/Product/Nodejs/Debugger/Serialization/NodeBacktraceVariable.cs#L33 have value of type Newtonsoft.Json.Linq.JTokenType.Date which is converted to local time by the library

@kant2002
Copy link
Contributor

Not so simple as it seems from the first sight.
Node respond correct value ..{"ref":8,"type":"string","value":"2015-05-07T22:00:00.000Z"}.., but Newtonsoft.JSON parse value as DateTime and then corresponding value in the debugger looks like

...
{
  "ref": 8,
  "type": "string",
  "value": "2015-05-07T22:00:00Z"
}...

and there no way to recover that information.
So far to have workaround for that issues we have eaither

  1. to override some deserialization logic, so no DateTime deserializatin would happens
  2. or to create strict types for the debugger commands, and explicitly define schema for Node.JS debug protocol.

@kant2002
Copy link
Contributor

@mousetraps could you take a look?

@billti
Copy link
Member

billti commented Sep 8, 2015

Seems like that DateParse enumeration should be 'None' for the value field if you don't want it converted. See http://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_DateParseHandling.htm

@kant2002
Copy link
Contributor

kant2002 commented Sep 8, 2015

I will try that. Thanks. Exactly what I was looking for. Will comeback when test that.

@billti billti modified the milestones: Future, August Sep 11, 2015
@mousetraps mousetraps modified the milestones: September, Future Sep 24, 2015
@mousetraps mousetraps removed this from the September milestone Sep 24, 2015
kant2002 added a commit to kant2002/nodejstools that referenced this issue Nov 14, 2015
kant2002 added a commit to kant2002/nodejstools that referenced this issue Dec 10, 2015
mjbvz added a commit to mjbvz/nodejstools that referenced this issue Apr 26, 2016
Addresses microsoft#106. Json.net will automatically try to parse strings that look like date strings. If one of these is recieved as the value in a Node debug message, we end up displaying the wrong value in the debugger.

Fix, make sure we always use DateTimeParse.None when dealing with messages from the debugger. If we do need to parse a date string, we should handle those cases explicitly.

closes microsoft#106
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment