Author Topic: Null date not displayed correctly  (Read 2821 times)

TeeJT

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Null date not displayed correctly
« on: February 28, 2017, 01:07:18 pm »
I am using ParamQuery Pro v3.3.4
The null date for this "format": "dd-M-yy" in the column model appears as: NaN-undefined-NaN
I noticed that your sample displays the null date as blank - https://paramquery.com/pro/demos/filter_header_local

By the way, I included mement.js - does this affect ParamQuery?
« Last Edit: February 28, 2017, 01:12:14 pm by TeeJT »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Null date not displayed correctly
« Reply #1 on: February 28, 2017, 03:16:45 pm »
paramquery uses jqueryui formatDate method to format dates.

$.datepicker.formatDate('dd-M-yy', null) returns "", I'm not sure what's wrong in your case. It would be easier to find out if you could please share a jsfiddle.

BTW have you added dataType: 'date' to the column?

TeeJT

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Null date not displayed correctly
« Reply #2 on: March 01, 2017, 09:56:14 am »
I have found out the problem. In my company we are using stdlib.js from http://stdlibjs.com/
This caused the problem.
When the format is dd-M-yy for a null date - the display is NaN-undefined-NaN
When I remove this script - it is OK.
Can I do a prototype to overcome this problem?
We need to use stdlib.js in our projects.
The version we use is - http://teejt.drivehq.com/testing/Visual/ParamQuery/stdlib.js
I tried to attach it but it was not allowed
« Last Edit: March 01, 2017, 10:12:31 am by TeeJT »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Null date not displayed correctly
« Reply #3 on: March 02, 2017, 09:44:33 am »
stdlib turns out to be incompatible with ParamQuery.

As I checked, stdlib modifies Date.parse() so that Date.parse(undefined) returns current date ( which is non-standard ) whereas it returns NaN in the browsers.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

TeeJT

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 88
    • View Profile
Re: Null date not displayed correctly
« Reply #4 on: March 02, 2017, 12:10:23 pm »
Thanks! I have also found that the Date.parse was giving the problem and have commented it out. Yes indeed for undefined it returns current date and time.