javascriptjquerynode.jsnode-modulesdatejs

Datejs lib not working after Upgrade to J-Query 3.x


I have a node.js project where we are using the following lib.

https://github.com/datejs/Datejs

After a recent update of our local J-Query file from 1.9.1 to 3.6.0 this lib stopped working.

Sample Code

    var today = Date.today();

Errors

TypeError: Date.today is not a function at Object. (main.js:8:126614)

Cannot read properties of undefined (reading 'includes')

TypeError: i.add is not a function

When I change the code to

var today = new Date();
var numberOfDays = today.add(5).days();

Then there is a problem with the add method, see the error listed above.

Question, is there anyway to make this lib work with the latest J-Query? The repo appears old and stale, no new releases since 2007, is there any other similar libs that I could try?


Solution

  • Sorry, I think I finally found the answer.

    var parsedate = require('datejs');

    Basically, this line was previously removed to help clean-up un-used variables, the previous Jquery upgrade caused issues with the loading order of some of our js files. Although parsedate is never used, this line is still needed to include the datejs lib.

    #Winning #TigerBlood