Javascript String FromWCFDate(throwOnInvalidInput)

Description

Javascript String FromWCFDate(throwOnInvalidInput)


String.prototype.FromWCFDate = function (throwOnInvalidInput) {
        var pattern = /Date\(([^)]+)\)/;
        var results = pattern.exec(this);
        if (results.length != 2) {
            if (!throwOnInvalidInput) {
                return this;
            }/* www . j a  v  a2s .  c o m*/
            throw new Error(this + " is not .net json date.");
        }
        return new Date(parseFloat(results[1]));
    };



PreviousNext

Related