summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/pyeval.js
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2012-12-10 13:54:23 +0100
committerThibault Delavallée <tde@openerp.com>2012-12-10 13:54:23 +0100
commit1ca5e68b1f3ddb440b104c6c47ea35e8d26a1eed (patch)
tree4070b56d1253290fa69f4fbc43ad4862c883080e /addons/web/static/src/js/pyeval.js
parenta5ca416f055871fb2765567c2cf2f06445c1d2ca (diff)
parent70f8f99b35c93a880cf15a1f21b7f88aef5a8d36 (diff)
[MERGE] Sync with trunk.
bzr revid: tde@openerp.com-20121130093732-i8y10ayjqiaq5t7p bzr revid: tde@openerp.com-20121204142854-pauouyapnw7z8zwj bzr revid: tde@openerp.com-20121205101544-k4ui6thr0ibzw0vx bzr revid: tde@openerp.com-20121210125423-81wbh4af9sxdqjki
Diffstat (limited to 'addons/web/static/src/js/pyeval.js')
-rw-r--r--addons/web/static/src/js/pyeval.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/addons/web/static/src/js/pyeval.js b/addons/web/static/src/js/pyeval.js
index 265449f9f64..2c1b5ec9d7d 100644
--- a/addons/web/static/src/js/pyeval.js
+++ b/addons/web/static/src/js/pyeval.js
@@ -24,7 +24,7 @@ openerp.web.pyeval = function (instance) {
var mod = a%b;
// in python, sign(a % b) === sign(b). Not in JS. If wrong side, add a
// round of b
- if (mod > 0 && b < 0 || mod < 0 && b > 0) {
+ if (mod > 0 && b < 0 || mod < 0 && b > 0) {
mod += b;
}
return fn(Math.floor(a/b), mod);
@@ -398,14 +398,9 @@ openerp.web.pyeval = function (instance) {
now: py.classmethod.fromJSON(function () {
var d = new Date();
return py.PY_call(datetime.datetime,
- [d.getFullYear(), d.getMonth() + 1, d.getDate(),
- d.getHours(), d.getMinutes(), d.getSeconds(),
- d.getMilliseconds() * 1000]);
- }),
- today: py.classmethod.fromJSON(function () {
- var d = new Date();
- return py.PY_call(datetime.datetime,
- [d.getFullYear(), d.getMonth() + 1, d.getDate()]);
+ [d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(),
+ d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(),
+ d.getUTCMilliseconds() * 1000]);
}),
combine: py.classmethod.fromJSON(function () {
var args = py.PY_parseArgs(arguments, 'date time');
@@ -439,11 +434,6 @@ openerp.web.pyeval = function (instance) {
throw new Error('ValueError: No known conversion for ' + m);
}));
},
- today: py.classmethod.fromJSON(function () {
- var d = new Date();
- return py.PY_call(
- datetime.date, [d.getFullYear(), d.getMonth() + 1, d.getDate()]);
- }),
__eq__: function (other) {
return (this.year === other.year
&& this.month === other.month
@@ -479,6 +469,17 @@ openerp.web.pyeval = function (instance) {
return py.PY_call(datetime.date, [year, month, day])
}
});
+ /**
+ Returns the current local date, which means the date on the client (which can be different
+ compared to the date of the server).
+
+ @return {datetime.date}
+ */
+ var context_today = function() {
+ var d = new Date();
+ return py.PY_call(
+ datetime.date, [d.getFullYear(), d.getMonth() + 1, d.getDate()]);
+ };
datetime.time = py.type('time', null, {
__init__: function () {
var zero = py.float.fromJSON(0);
@@ -691,6 +692,7 @@ openerp.web.pyeval = function (instance) {
return {
uid: py.float.fromJSON(instance.session.uid),
datetime: datetime,
+ context_today: context_today,
time: time,
relativedelta: relativedelta,
current_date: py.PY_call(