Merge pull request #16844 from surajshetty3416/fix-date-inconsistency

fix(date control): Do not try to convert timezone of date
This commit is contained in:
Suraj Shetty 2022-05-06 13:43:33 +05:30 committed by GitHub
commit fa15bd2758
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View file

@ -137,13 +137,13 @@ frappe.ui.form.ControlDate = class ControlDate extends frappe.ui.form.ControlDat
});
}
parse(value) {
if(value) {
return frappe.datetime.user_to_str(value);
if (value) {
return frappe.datetime.user_to_str(value, false, true);
}
}
format_for_input(value) {
if(value) {
return frappe.datetime.str_to_user(value);
if (value) {
return frappe.datetime.str_to_user(value, false, true);
}
return "";
}

View file

@ -45,8 +45,6 @@ frappe.ui.form.ControlDatetime = class ControlDatetime extends frappe.ui.form.Co
}
format_for_input(value) {
if (!value) return "";
return frappe.datetime.str_to_user(value, false);
}
set_description() {

View file

@ -133,7 +133,7 @@ $.extend(frappe.datetime, {
return frappe.sys_defaults && frappe.sys_defaults.date_format || "yyyy-mm-dd";
},
str_to_user: function(val, only_time = false) {
str_to_user: function(val, only_time=false, only_date=false) {
if (!val) return "";
const user_date_fmt = frappe.datetime.get_user_date_fmt().toUpperCase();
const user_time_fmt = frappe.datetime.get_user_time_fmt();
@ -142,6 +142,9 @@ $.extend(frappe.datetime, {
if (only_time) {
let date_obj = moment(val, frappe.defaultTimeFormat);
return date_obj.format(user_format);
} else if (only_date) {
let date_obj = moment(val, frappe.defaultDateFormat);
return date_obj.format(user_date_fmt);
} else {
let date_obj = moment.tz(val, frappe.boot.time_zone.system);
if (typeof val !== "string" || val.indexOf(" ") === -1) {