Retrieve time zone from user preferences

pull/1610/head
Hagen Schink 10 years ago
parent 218f27ea11
commit febe47c223
  1. 6
      app/assets/javascripts/angular/config/configuration-service.js
  2. 12
      app/assets/javascripts/angular/services/timezone-service.js

@ -54,6 +54,12 @@ angular.module('openproject.config')
} else {
return gon.settings.user_preferences.others.comments_sorting === 'desc';
}
},
isTimezoneSet: function() {
return this.userPreferencesPresent() && gon.settings.user_preferences.time_zone != '';
},
timezone: function() {
return (isTimezoneSet()) ? gon.settings.user_preferences.time_zone : '';
}
};
}]);

@ -28,19 +28,13 @@
angular.module('openproject.services')
.service('TimezoneService', [function() {
var timezoneOptions = {
name: ''
};
.service('TimezoneService', ['ConfigurationService', function(ConfigurationService) {
TimezoneService = {
setTimezone: function(name) {
timezoneOptions.name = name;
},
parseDate: function(date) {
var d = moment.utc(date, "MM/DD/YYYY/ HH:mm A");
if (timezoneOptions.name) {
d.tz(timezoneOptions.name);
if (ConfigurationService.isTimezoneSet()) {
d.tz(ConfigurationService.timezone());
}
return d;

Loading…
Cancel
Save