# SINCE 0.5.0\r
web.repositoriesMessage = gitblit\r
\r
+# Manually set the default timezone to be used by Gitblit for display in the \r
+# web ui. This value is independent of the JVM timezone. Specifying a blank\r
+# value will default to the JVM timezone.\r
+# e.g. America/New_York, US/Pacific, UTC, Europe/Berlin\r
+#\r
+# SINCE 0.9.0\r
+# RESTART REQUIRED\r
+web.timezone =\r
+\r
# Use the client timezone when formatting dates.\r
# This uses AJAX to determine the browser's timezone and may require more\r
# server overhead because a Wicket session is created. All Gitblit pages\r
\r
#### changes\r
\r
-- block pushes to a repository with a working copy (i.e. non-bare repository) (issue-49)\r
-- web.datetimestampLongFormat from *EEEE, MMMM d, yyyy h:mm a z* to *EEEE, MMMM d, yyyy HH:mm Z* (issue 50)\r
-- expanded commit age coloring from 2 days to 30 days (issue 57)\r
+- Block pushes to a repository with a working copy (i.e. non-bare repository) (issue-49)\r
+- Changed default web.datetimestampLongFormat from *EEEE, MMMM d, yyyy h:mm a z* to *EEEE, MMMM d, yyyy HH:mm Z* (issue 50)\r
+- Expanded commit age coloring from 2 days to 30 days (issue 57)\r
\r
#### additions\r
\r
+- Allow specifying timezone to use for Gitblit which is independent of both the JVM and the system timezone (issue 54) \r
+ **New:** *web.timezone =* \r
- Added a built-in AJP connector for integrating Gitblit GO into an Apache mod_proxy setup (issue 59) \r
**New:** *server.ajpPort = 0* \r
**New:** *server.ajpBindInterface = localhost*\r
\r
#### fixes \r
\r
+- Fixed timezone bug on the activity apge (issue 54)\r
- Prevent add/edit team with no selected repositories (issue 56) \r
- Disallow browser autocomplete on add/edit user/team/repository pages\r
- Fixed username case-sensitivity issues (issue 43)\r
import java.io.InputStreamReader;\r
import java.lang.reflect.Field;\r
import java.text.MessageFormat;\r
+import java.text.SimpleDateFormat;\r
import java.util.ArrayList;\r
import java.util.Arrays;\r
import java.util.Collection;\r
import java.util.Collections;\r
+import java.util.Date;\r
import java.util.HashMap;\r
import java.util.LinkedHashSet;\r
import java.util.List;\r
import java.util.Map;\r
import java.util.Map.Entry;\r
import java.util.Set;\r
+import java.util.TimeZone;\r
import java.util.TreeSet;\r
import java.util.concurrent.ConcurrentHashMap;\r
import java.util.concurrent.Executors;\r
public class GitBlit implements ServletContextListener {\r
\r
private static GitBlit gitblit;\r
-\r
+ \r
private final Logger logger = LoggerFactory.getLogger(GitBlit.class);\r
\r
private final ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(5);\r
private ServerStatus serverStatus;\r
\r
private MailExecutor mailExecutor;\r
+ \r
+ private TimeZone timezone;\r
\r
public GitBlit() {\r
if (gitblit == null) {\r
public static boolean isGO() {\r
return self().settings instanceof FileSettings;\r
}\r
+ \r
+ /**\r
+ * Returns the preferred timezone for the Gitblit instance.\r
+ * \r
+ * @return a timezone\r
+ */\r
+ public static TimeZone getTimezone() {\r
+ if (self().timezone == null) {\r
+ String tzid = getString("web.timezone", null);\r
+ if (StringUtils.isEmpty(tzid)) {\r
+ self().timezone = TimeZone.getDefault();\r
+ return self().timezone;\r
+ }\r
+ self().timezone = TimeZone.getTimeZone(tzid);\r
+ }\r
+ return self().timezone;\r
+ }\r
\r
/**\r
* Returns the boolean value for the specified key. If the key does not\r
repositoriesFolder = getRepositoriesFolder();\r
logger.info("Git repositories folder " + repositoriesFolder.getAbsolutePath());\r
repositoryResolver = new FileResolver<Void>(repositoriesFolder, true);\r
+ \r
+ logTimezone("JVM", TimeZone.getDefault());\r
+ logTimezone(Constants.NAME, getTimezone());\r
+\r
serverStatus = new ServerStatus(isGO());\r
String realm = settings.getString(Keys.realm.userService, "users.properties");\r
IUserService loginService = null;\r
}\r
if (startFederation) {\r
configureFederation();\r
- }\r
+ } \r
+ }\r
+ \r
+ private void logTimezone(String type, TimeZone zone) {\r
+ SimpleDateFormat df = new SimpleDateFormat("z Z");\r
+ df.setTimeZone(zone);\r
+ String offset = df.format(new Date());\r
+ logger.info(type + " timezone is " + zone.getID() + " (" + offset + ")");\r
}\r
\r
/**\r
public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone) {\r
String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");\r
DateFormat df = new SimpleDateFormat(format);\r
- if (timeZone != null) {\r
- df.setTimeZone(timeZone);\r
+ if (timeZone == null) {\r
+ timeZone = GitBlit.getTimezone();\r
}\r
+ df.setTimeZone(timeZone);\r
String dateString;\r
if (date.getTime() == 0) {\r
dateString = "--";\r
public static Label createTimeLabel(String wicketId, Date date, TimeZone timeZone) {\r
String format = GitBlit.getString(Keys.web.timeFormat, "HH:mm");\r
DateFormat df = new SimpleDateFormat(format);\r
- if (timeZone != null) {\r
- df.setTimeZone(timeZone);\r
+ if (timeZone == null) {\r
+ timeZone = GitBlit.getTimezone();\r
}\r
+ df.setTimeZone(timeZone);\r
String timeString;\r
if (date.getTime() == 0) {\r
timeString = "--";\r
}\r
String title = TimeUtils.timeAgo(date);\r
Label label = new Label(wicketId, timeString);\r
- WicketUtils.setCssClass(label, TimeUtils.timeAgoCss(date));\r
if (!StringUtils.isEmpty(title)) {\r
WicketUtils.setHtmlTooltip(label, title);\r
}\r
public static Label createDatestampLabel(String wicketId, Date date, TimeZone timeZone) {\r
String format = GitBlit.getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy");\r
DateFormat df = new SimpleDateFormat(format);\r
- if (timeZone != null) {\r
- df.setTimeZone(timeZone);\r
+ if (timeZone == null) {\r
+ timeZone = GitBlit.getTimezone();\r
}\r
+ df.setTimeZone(timeZone);\r
String dateString;\r
if (date.getTime() == 0) {\r
dateString = "--";\r
title = tmp;\r
}\r
Label label = new Label(wicketId, dateString);\r
- WicketUtils.setCssClass(label, TimeUtils.timeAgoCss(date));\r
if (!StringUtils.isEmpty(title)) {\r
WicketUtils.setHtmlTooltip(label, title);\r
}\r
String format = GitBlit.getString(Keys.web.datetimestampLongFormat,\r
"EEEE, MMMM d, yyyy HH:mm Z");\r
DateFormat df = new SimpleDateFormat(format);\r
- if (timeZone != null) {\r
- df.setTimeZone(timeZone);\r
+ if (timeZone == null) {\r
+ timeZone = GitBlit.getTimezone();\r
}\r
+ df.setTimeZone(timeZone);\r
String dateString;\r
if (date.getTime() == 0) {\r
dateString = "--";\r
\r
protected TimeZone getTimeZone() {\r
return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()\r
- .getTimezone() : TimeZone.getDefault();\r
+ .getTimezone() : GitBlit.getTimezone();\r
}\r
\r
protected String getServerName() {\r
\r
protected TimeZone getTimeZone() {\r
return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()\r
- .getTimezone() : TimeZone.getDefault();\r
+ .getTimezone() : GitBlit.getTimezone();\r
}\r
\r
protected void setPersonSearchTooltip(Component component, String value, Constants.SearchType searchType) {\r