summaryrefslogtreecommitdiff
path: root/addons/base/static/src/js
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2011-05-11 16:44:31 +0200
committerniv-openerp <nicolas.vanhoren@openerp.com>2011-05-11 16:44:31 +0200
commite1fea6060a34006c357d5327eae85281adbb4d73 (patch)
tree805cae29e34302d64019d024dfa8ef4e7b89f0d6 /addons/base/static/src/js
parentd71f850481116f7b58116073dd4776f29771524d (diff)
[IMP] Added documentation to dates.js.
bzr revid: nicolas.vanhoren@openerp.com-20110511144431-irjzvd1trbj8ejwb
Diffstat (limited to 'addons/base/static/src/js')
-rw-r--r--addons/base/static/src/js/dates.js50
1 files changed, 49 insertions, 1 deletions
diff --git a/addons/base/static/src/js/dates.js b/addons/base/static/src/js/dates.js
index da4e948e282..43656fd0ed8 100644
--- a/addons/base/static/src/js/dates.js
+++ b/addons/base/static/src/js/dates.js
@@ -1,6 +1,16 @@
openerp.base.dates = function(openerp) {
+/**
+ * Converts a string to a Date javascript object using OpenERP's
+ * datetime string format (exemple: '2011-12-01 15:12:35').
+ *
+ * The timezone is assumed to be UTC (standard for OpenERP 6.1)
+ * and will be converted to the browser's timezone.
+ *
+ * @param {String} str A string representing a datetime.
+ * @returns {Date}
+ */
openerp.base.parse_datetime = function(str) {
if(!str) {
return str;
@@ -17,6 +27,13 @@ openerp.base.parse_datetime = function(str) {
return obj;
};
+/**
+ * Converts a string to a Date javascript object using OpenERP's
+ * date string format (exemple: '2011-12-01').
+ *
+ * @param {String} str A string representing a date.
+ * @returns {Date}
+ */
openerp.base.parse_date = function(str) {
if(!str) {
return str;
@@ -33,6 +50,13 @@ openerp.base.parse_date = function(str) {
return obj;
};
+/**
+ * Converts a string to a Date javascript object using OpenERP's
+ * time string format (exemple: '15:12:35').
+ *
+ * @param {String} str A string representing a time.
+ * @returns {Date}
+ */
openerp.base.parse_time = function(str) {
if(!str) {
return str;
@@ -49,7 +73,7 @@ openerp.base.parse_time = function(str) {
return obj;
};
-/**
+/*
* Just a simple function to add some '0' if an integer it too small.
*/
var fts = function(str, size) {
@@ -61,6 +85,16 @@ var fts = function(str, size) {
return to_add + str;
};
+/**
+ * Converts a Date javascript object to a string using OpenERP's
+ * datetime string format (exemple: '2011-12-01 15:12:35').
+ *
+ * The timezone of the Date object is assumed to be the one of the
+ * browser and it will be converted to UTC (standard for OpenERP 6.1).
+ *
+ * @param {Date} obj
+ * @returns {String} A string representing a datetime.
+ */
openerp.base.format_datetime = function(obj) {
if(! str) {
return false;
@@ -70,6 +104,13 @@ openerp.base.format_datetime = function(obj) {
+ fts(obj.getUTCMinutes(),2) + ":" + fts(obj.getUTCSeconds(),2);
};
+/**
+ * Converts a Date javascript object to a string using OpenERP's
+ * date string format (exemple: '2011-12-01').
+ *
+ * @param {Date} obj
+ * @returns {String} A string representing a date.
+ */
openerp.base.format_date = function(obj) {
if(! str) {
return false;
@@ -78,6 +119,13 @@ openerp.base.format_date = function(obj) {
+ fts(obj.getDate(),2);
};
+/**
+ * Converts a Date javascript object to a string using OpenERP's
+ * time string format (exemple: '15:12:35').
+ *
+ * @param {Date} obj
+ * @returns {String} A string representing a time.
+ */
openerp.base.format_time = function(obj) {
if(! str) {
return false;