[ADD] pyeval: date.replace method

Needed to create filters like "previous month"

It was just defined for "datetime", but is also needed for "date"

closes #2915
This commit is contained in:
Mario Arias Badila 2014-10-05 14:25:08 -06:00 committed by Xavier Morel
parent b374c51474
commit bd2633753d
1 changed files with 13 additions and 0 deletions

View File

@ -479,6 +479,19 @@
&& this.day === other.day)
? py.True : py.False;
},
replace: function () {
var args = py.PY_parseArgs(arguments, [
['year', py.None], ['month', py.None], ['day', py.None]
]);
var params = {};
for(var key in args) {
if (!args.hasOwnProperty(key)) { continue; }
var arg = args[key];
params[key] = (arg === py.None ? this[key] : asJS(arg));
}
return py.PY_call(datetime.date, params);
},
__add__: function (other) {
if (!py.PY_isInstance(other, datetime.timedelta)) {
return py.NotImplemented;