Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#48100] Add default time zone of the instance set by the administrator into configuration service

Dombi Attila1eb8e17f913b
diff --git a/frontend/src/app/core/config/configuration.service.ts b/frontend/src/app/core/config/configuration.service.ts
index 0fd8f87017a..17a274d7be3 100644
--- a/frontend/src/app/core/config/configuration.service.ts
+++ b/frontend/src/app/core/config/configuration.service.ts
@@ -99,6 +99,10 @@ export class ConfigurationService {
return this.systemPreference('timeFormat');
}
+ public defaultTimezone():string {
+ return this.systemPreference('userDefaultTimezone');
+ }
+
public startOfWeekPresent():boolean {
return !!this.systemPreference('startOfWeek');
}
diff --git a/lib/api/v3/configuration/configuration_representer.rb b/lib/api/v3/configuration/configuration_representer.rb
index 5e5d88c4be1..7612d9f9b02 100644
--- a/lib/api/v3/configuration/configuration_representer.rb
+++ b/lib/api/v3/configuration/configuration_representer.rb
@@ -67,6 +67,9 @@ module API
exec_context: :decorator,
render_nil: true
+ property :user_default_timezone,
+ render_nil: true
+
property :start_of_week,
getter: ->(*) {
Setting.start_of_week.to_i if Setting.start_of_week.present?
diff --git a/spec/lib/api/v3/configuration/configuration_representer_spec.rb b/spec/lib/api/v3/configuration/configuration_representer_spec.rb
index 2a61655d525..0f39f36edea 100644
--- a/spec/lib/api/v3/configuration/configuration_representer_spec.rb
+++ b/spec/lib/api/v3/configuration/configuration_representer_spec.rb
@@ -186,6 +186,24 @@ describe API::V3::Configuration::ConfigurationRepresenter do
end
end
+ describe 'user_default_timezone' do
+ context 'without a setting', with_settings: { user_default_timezone: nil } do
+ it 'is null' do
+ expect(subject)
+ .to be_json_eql(nil.to_json)
+ .at_path('userDefaultTimezone')
+ end
+ end
+
+ context 'with `Europe/Berlin` being set', with_settings: { user_default_timezone: 'Europe/Berlin' } do
+ it 'indicates the dateFormat' do
+ expect(subject)
+ .to be_json_eql('Europe/Berlin'.to_json)
+ .at_path('userDefaultTimezone')
+ end
+ end
+ end
+
describe 'startOfWeek' do
context 'without a setting', with_settings: { start_of_week: '' } do
it 'is null' do