Search code examples
javascriptdatejs

JavaScript native or jQuery library call


Is there a way to determine which method is used when doing JavaScript coding. I'm playing around with datejs library and method Date.parse and Javascript Date.parse

How can I know which one is doing its job?

http://jsfiddle.net/wilfff/DL6QZ/2/

var d = "Wed Apr 29 08:53:31 +0000 2009";
function parse_date(date_str) {
    return Date.parse(date_str.replace(/^([a-z]{3})( [a-z]{3} \d\d?)(.*)( \d{4})$/i, '$1,$2$4$3'));
}
$(".foo1").text(parse_date(d));

(remove the External Resources and run again) to view the difference.

Any idea how to handle this?

Cheers!


Solution

  • For something like this I would do my own check, and I would check for something I know would only exist, if the library is loaded. In this case you can check this:

    if(Date.CultureInfo){
       // i know now I'm using the external date library
    }else{
       // using the browsers native code
    }