score:1

Accepted answer

if you can change how it's generated, generate this instead

var usdeur = [
    [date.utc(2004, 3 - 1, 31), 0],
    [date.utc(2004, 4 - 1, 1), 0.134879956838416],
    [date.utc(2004, 4 - 1, 2), 0.471580293538753],
    [date.utc(2004, 4 - 1, 3), 0.473578515121543],
    [date.utc(2004, 4 - 1, 4), 0.474577625912938],
];

if you have no way of fixing the generated code, you may be able to put a custom date.utc function in before it's evaluated, and undo this after.

(function () {
    var utc = date.utc, slice = array.prototype.slice;
    date.utc = function () { // method to take `1` based months
        var args = slice.apply(arguments);
        if (args.length > 2) // fix your months
            args[1] -= 1;
        return utc.apply(date, args);
    };
    date.utc.restore = function () { // method to undo changes
        date.utc = utc;
    };
}());
// eval your array
// ...
// restore original behaviour
date.utc.restore();

score:1

in general you can subtract month with such expression:

var d = new date.utc(2004, 3, 31);
d.setmonth(d.getmonth()-1);
console.log(d); // minus one month

with array you can do something like this:

for (var i = 0; i < usdeur.length; i++) {
    var date = usdeur[i][0];
    date.setmonth(date.getmonth()-1);
    usdeur[i][0] = date;
}

Related Query

More Query from same tag