[imp] simplified formatting functions for dates
bzr revid: nicolas.vanhoren@openerp.com-20110921123139-f57zgqwdghl2qbf7
This commit is contained in:
parent
650cd80e71
commit
67271d1e91
|
@ -118,26 +118,26 @@ openerp.web.parse_value = function (value, descriptor, value_if_empty) {
|
|||
var tmp = Date.parseExact(value, _.sprintf("%s %s", Date.CultureInfo.formatPatterns.shortDate,
|
||||
Date.CultureInfo.formatPatterns.longTime));
|
||||
if (tmp !== null)
|
||||
return tmp;
|
||||
return openerp.web.datetime_to_str(tmp);
|
||||
tmp = Date.parse(value);
|
||||
if (tmp !== null)
|
||||
return tmp;
|
||||
return openerp.web.datetime_to_str(tmp);
|
||||
throw value + " is not a valid datetime";
|
||||
case 'date':
|
||||
var tmp = Date.parseExact(value, Date.CultureInfo.formatPatterns.shortDate);
|
||||
if (tmp !== null)
|
||||
return tmp;
|
||||
return openerp.web.date_to_str(tmp);
|
||||
tmp = Date.parse(value);
|
||||
if (tmp !== null)
|
||||
return tmp;
|
||||
return openerp.web.date_to_str(tmp);
|
||||
throw value + " is not a valid date";
|
||||
case 'time':
|
||||
var tmp = Date.parseExact(value, Date.CultureInfo.formatPatterns.longTime);
|
||||
if (tmp !== null)
|
||||
return tmp;
|
||||
return openerp.web.time_to_str(tmp);
|
||||
tmp = Date.parse(value);
|
||||
if (tmp !== null)
|
||||
return tmp;
|
||||
return openerp.web.time_to_str(tmp);
|
||||
throw value + " is not a valid time";
|
||||
}
|
||||
return value;
|
||||
|
|
|
@ -1146,6 +1146,7 @@ openerp.web.DateTimeWidget = openerp.web.Widget.extend({
|
|||
self.$element.find('.oe_datepicker').hide();
|
||||
});
|
||||
this.set_readonly(false);
|
||||
this.value = false;
|
||||
},
|
||||
picker: function() {
|
||||
return $.fn[this.jqueryui_object].apply(this.$element.find('.oe_datepicker_container'), arguments);
|
||||
|
@ -1155,12 +1156,11 @@ openerp.web.DateTimeWidget = openerp.web.Widget.extend({
|
|||
this.$element.find('input').val(date ? this.format_client(date) : '').change();
|
||||
},
|
||||
set_value: function(value) {
|
||||
value = this.parse(value);
|
||||
this.value = value;
|
||||
this.$element.find('input').val(value ? this.format_client(value) : '');
|
||||
},
|
||||
get_value: function() {
|
||||
return this.format(this.value);
|
||||
return this.value;
|
||||
},
|
||||
set_value_from_ui: function() {
|
||||
var value = this.$element.find('input').val() || false;
|
||||
|
@ -1187,13 +1187,9 @@ openerp.web.DateTimeWidget = openerp.web.Widget.extend({
|
|||
focus: function() {
|
||||
this.$element.find('input').focus();
|
||||
},
|
||||
parse: openerp.web.auto_str_to_date,
|
||||
parse_client: function(v) {
|
||||
return openerp.web.parse_value(v, {"widget": this.type_of_date});
|
||||
},
|
||||
format: function(val) {
|
||||
return openerp.web.auto_date_to_str(val, this.type_of_date);
|
||||
},
|
||||
format_client: function(v) {
|
||||
return openerp.web.format_value(v, {"widget": this.type_of_date});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue