locked
Invalid Date error on new Date()

    Question

  • I am losing my mind. I am getting 'invalid date' whenever I create a new Date object in VS2012 Ultimate with the RTM bits. Anyone else see this?

    http://i.imgur.com/tl4Yv.png

    I just tried it with a new project, and it doesn't work there either. What did I bork up?

    S



    Check out my new C# 2010 All In One for Dummies book at Amazon!

    Tuesday, September 18, 2012 12:58 PM

Answers

  • According to the WinJS team, that is expected behavior, because there is no concept in JavaScript for the WinRT Date object.

    However, is doesn't explain why I could use it in a Notification last month, and I can't now.

    I'll try your TryParse idea.

    S


    http://www.sempf.net/

    Monday, September 24, 2012 12:43 PM

All replies

  • I'm not sure, but I am able to create dates in the same way without problems.

    Dave Paquette @Dave_Paquette www.davepaquette.com

    Tuesday, September 18, 2012 3:31 PM
  • Well that stinks.

    Any ideas from anyone here? I'm kinda stuck.

    S


    Check out my new C# 2010 All In One for Dummies book at Amazon!

    Wednesday, September 19, 2012 12:18 PM
  • I see that all the time too, but it doesn't seem to affect being able to use the date.  Are you actually having trouble using the date after you create it?
    Wednesday, September 19, 2012 7:50 PM
  • Yes.

    If you pass it into a WinRT function that expects a Date, you'll get an illegal parameter error.

    For instance, scheduling a notification.

    S


    http://www.sempf.net/

    Wednesday, September 19, 2012 8:28 PM
  • Hmm, interesting.  I'm not surprised by this.

    I don't think we are passing dates back up into WinRT functions, mainly using in UI.  I'll take a look to see if we are doing anything similar.  My guess is no since we haven't run into this.

    But it's been bothering me as well that whenever I create a date I see that when debugging.

    Wednesday, September 19, 2012 8:42 PM
  • Just a thought, you can only return a DateTimeOffset to javascript from a WinRT function.  Wonder if it's the same issue the other way.

    Have you tried passing the date in as a string and just doing a TryParse on the other side. I know that seems like a hack.

    Just for grins, I created a new date using all three constructors and sure enough, they all get the same "Invalid Date" in the prototype. This feels like a bug to me.

    Thursday, September 20, 2012 12:38 PM
  • According to the WinJS team, that is expected behavior, because there is no concept in JavaScript for the WinRT Date object.

    However, is doesn't explain why I could use it in a Notification last month, and I can't now.

    I'll try your TryParse idea.

    S


    http://www.sempf.net/

    Monday, September 24, 2012 12:43 PM