From 593a287c8d0cfcc22ca2db35dc9a72140e296c2e Mon Sep 17 00:00:00 2001
From: Sullivan SENECHAL <soullivaneuh@gmail.com>
Date: Sat, 11 Oct 2014 13:10:41 +0200
Subject: [PATCH] Add timezone configuration to gitlab.yml

---
 CHANGELOG                         | 3 +++
 config/application.rb             | 1 +
 config/gitlab.yml.example         | 5 +++++
 config/initializers/1_settings.rb | 1 +
 config/initializers/time_zone.rb  | 1 +
 5 files changed, 11 insertions(+)
 create mode 100644 config/initializers/time_zone.rb

diff --git a/CHANGELOG b/CHANGELOG
index 05290698320..f82ef4b4c78 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v 7.5.0
+  - Add time zone configuration on gitlab.yml (Sullivan Senechal)
+
 v 7.4.0
   - Refactored membership logic
   - Improve error reporting on users API (Julien Bianchi)
diff --git a/config/application.rb b/config/application.rb
index e36df913d0b..85c83f74a95 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -25,6 +25,7 @@ module Gitlab
 
     # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
     # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+    # NOTE: Please prefer set time zone on config/gitlab.yml configuration file.
     # config.time_zone = 'Central Time (US & Canada)'
 
     # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index e7a8d08dc83..2ca6abac576 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -33,6 +33,11 @@ production: &base
     # Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
     # user: git
 
+    ## Date & Time settings
+    # Uncomment and customize if you want to change the default time zone of GitLab application.
+    # To see all available zones, run `bundle exec rake time:zones:all`
+    # time_zone: 'UTC'
+
     ## Email settings
     # Email address used in the "From" field in mails sent by GitLab
     email_from: example@example.com
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 88cbaefea7d..4670791ddb0 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -103,6 +103,7 @@ Settings.gitlab['user_home']  ||= begin
 rescue ArgumentError # no user configured
   '/home/' + Settings.gitlab['user']
 end
+Settings.gitlab['time_zone']  ||= nil
 Settings.gitlab['signup_enabled'] ||= false
 Settings.gitlab['signin_enabled'] ||= true if Settings.gitlab['signin_enabled'].nil?
 Settings.gitlab['restricted_visibility_levels'] = Settings.send(:verify_constant_array, Gitlab::VisibilityLevel, Settings.gitlab['restricted_visibility_levels'], [])
diff --git a/config/initializers/time_zone.rb b/config/initializers/time_zone.rb
new file mode 100644
index 00000000000..ee246e67d66
--- /dev/null
+++ b/config/initializers/time_zone.rb
@@ -0,0 +1 @@
+Time.zone = Gitlab.config.gitlab.time_zone || Time.zone
-- 
GitLab