Merge pull request #1398 from anandpdoshi/datetime-timezone
[fix] conversion of datetime to user's timezone
This commit is contained in:
commit
cd33dd3335
2 changed files with 6 additions and 12 deletions
|
|
@ -81,14 +81,9 @@ frappe.Application = Class.extend({
|
|||
this.set_globals();
|
||||
this.sync_pages();
|
||||
moment.locale(frappe.boot.lang);
|
||||
moment.user_utc_offset = moment().utcOffset();
|
||||
if(frappe.boot.timezone_info) {
|
||||
moment.tz.add(frappe.boot.timezone_info);
|
||||
if(sys_defaults.time_zone) {
|
||||
moment.system_utc_offset = moment().tz(sys_defaults.time_zone).utcOffset();
|
||||
} else {
|
||||
moment.system_utc_offset = moment().utcOffset();
|
||||
}
|
||||
moment.user_utc_offset = moment().utcOffset();
|
||||
}
|
||||
if(frappe.boot.print_css) {
|
||||
frappe.dom.set_style(frappe.boot.print_css)
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@ frappe.provide("frappe.datetime");
|
|||
$.extend(frappe.datetime, {
|
||||
convert_to_user_tz: function(date, format) {
|
||||
// format defaults to true
|
||||
|
||||
if(sys_defaults.time_zone) {
|
||||
var date_obj = moment.tz(date, sys_defaults.time_zone).utc().utcOffset(moment.user_utc_offset);
|
||||
var date_obj = moment.tz(date, sys_defaults.time_zone).local();
|
||||
} else {
|
||||
var date_obj = moment(date);
|
||||
}
|
||||
|
|
@ -24,7 +23,7 @@ $.extend(frappe.datetime, {
|
|||
// format defaults to true
|
||||
|
||||
if(sys_defaults.time_zone) {
|
||||
var date_obj = moment(date).utc().utcOffset(moment.system_utc_offset);
|
||||
var date_obj = moment(date).tz(sys_defaults.time_zone);
|
||||
} else {
|
||||
var date_obj = moment(date);
|
||||
}
|
||||
|
|
@ -79,15 +78,15 @@ $.extend(frappe.datetime, {
|
|||
month_end: function() {
|
||||
return moment().endOf("month").format();
|
||||
},
|
||||
|
||||
|
||||
year_start: function(){
|
||||
return moment().startOf("year").format();
|
||||
},
|
||||
|
||||
|
||||
year_end: function(){
|
||||
return moment().endOf("year").format();
|
||||
},
|
||||
|
||||
|
||||
get_user_fmt: function() {
|
||||
return sys_defaults.date_format || "yyyy-mm-dd";
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue