summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--distrib/gitblit.properties9
-rw-r--r--docs/04_releases.mkd9
-rw-r--r--src/com/gitblit/GitBlit.java37
-rw-r--r--src/com/gitblit/wicket/WicketUtils.java22
-rw-r--r--src/com/gitblit/wicket/pages/BasePage.java2
-rw-r--r--src/com/gitblit/wicket/panels/BasePanel.java2
6 files changed, 64 insertions, 17 deletions
diff --git a/distrib/gitblit.properties b/distrib/gitblit.properties
index 27b0d1f9..2ac6598f 100644
--- a/distrib/gitblit.properties
+++ b/distrib/gitblit.properties
@@ -232,6 +232,15 @@ web.loginMessage = gitblit
# SINCE 0.5.0
web.repositoriesMessage = gitblit
+# Manually set the default timezone to be used by Gitblit for display in the
+# web ui. This value is independent of the JVM timezone. Specifying a blank
+# value will default to the JVM timezone.
+# e.g. America/New_York, US/Pacific, UTC, Europe/Berlin
+#
+# SINCE 0.9.0
+# RESTART REQUIRED
+web.timezone =
+
# Use the client timezone when formatting dates.
# This uses AJAX to determine the browser's timezone and may require more
# server overhead because a Wicket session is created. All Gitblit pages
diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd
index f6751138..21b96d20 100644
--- a/docs/04_releases.mkd
+++ b/docs/04_releases.mkd
@@ -10,12 +10,14 @@
#### changes
-- block pushes to a repository with a working copy (i.e. non-bare repository) (issue-49)
-- web.datetimestampLongFormat from *EEEE, MMMM d, yyyy h:mm a z* to *EEEE, MMMM d, yyyy HH:mm Z* (issue 50)
-- expanded commit age coloring from 2 days to 30 days (issue 57)
+- Block pushes to a repository with a working copy (i.e. non-bare repository) (issue-49)
+- Changed default web.datetimestampLongFormat from *EEEE, MMMM d, yyyy h:mm a z* to *EEEE, MMMM d, yyyy HH:mm Z* (issue 50)
+- Expanded commit age coloring from 2 days to 30 days (issue 57)
#### additions
+- Allow specifying timezone to use for Gitblit which is independent of both the JVM and the system timezone (issue 54)
+ **New:** *web.timezone =*
- Added a built-in AJP connector for integrating Gitblit GO into an Apache mod_proxy setup (issue 59)
**New:** *server.ajpPort = 0*
**New:** *server.ajpBindInterface = localhost*
@@ -28,6 +30,7 @@ Push requests to these repositories will be rejected.
#### fixes
+- Fixed timezone bug on the activity apge (issue 54)
- Prevent add/edit team with no selected repositories (issue 56)
- Disallow browser autocomplete on add/edit user/team/repository pages
- Fixed username case-sensitivity issues (issue 43)
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 7cb813fe..9c1cd40f 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -23,16 +23,19 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.TimeZone;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
@@ -103,7 +106,7 @@ import com.gitblit.utils.StringUtils;
public class GitBlit implements ServletContextListener {
private static GitBlit gitblit;
-
+
private final Logger logger = LoggerFactory.getLogger(GitBlit.class);
private final ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(5);
@@ -132,6 +135,8 @@ public class GitBlit implements ServletContextListener {
private ServerStatus serverStatus;
private MailExecutor mailExecutor;
+
+ private TimeZone timezone;
public GitBlit() {
if (gitblit == null) {
@@ -160,6 +165,23 @@ public class GitBlit implements ServletContextListener {
public static boolean isGO() {
return self().settings instanceof FileSettings;
}
+
+ /**
+ * Returns the preferred timezone for the Gitblit instance.
+ *
+ * @return a timezone
+ */
+ public static TimeZone getTimezone() {
+ if (self().timezone == null) {
+ String tzid = getString("web.timezone", null);
+ if (StringUtils.isEmpty(tzid)) {
+ self().timezone = TimeZone.getDefault();
+ return self().timezone;
+ }
+ self().timezone = TimeZone.getTimeZone(tzid);
+ }
+ return self().timezone;
+ }
/**
* Returns the boolean value for the specified key. If the key does not
@@ -1767,6 +1789,10 @@ public class GitBlit implements ServletContextListener {
repositoriesFolder = getRepositoriesFolder();
logger.info("Git repositories folder " + repositoriesFolder.getAbsolutePath());
repositoryResolver = new FileResolver<Void>(repositoriesFolder, true);
+
+ logTimezone("JVM", TimeZone.getDefault());
+ logTimezone(Constants.NAME, getTimezone());
+
serverStatus = new ServerStatus(isGO());
String realm = settings.getString(Keys.realm.userService, "users.properties");
IUserService loginService = null;
@@ -1786,7 +1812,14 @@ public class GitBlit implements ServletContextListener {
}
if (startFederation) {
configureFederation();
- }
+ }
+ }
+
+ private void logTimezone(String type, TimeZone zone) {
+ SimpleDateFormat df = new SimpleDateFormat("z Z");
+ df.setTimeZone(zone);
+ String offset = df.format(new Date());
+ logger.info(type + " timezone is " + zone.getID() + " (" + offset + ")");
}
/**
diff --git a/src/com/gitblit/wicket/WicketUtils.java b/src/com/gitblit/wicket/WicketUtils.java
index 8c1cf3c8..7be5328e 100644
--- a/src/com/gitblit/wicket/WicketUtils.java
+++ b/src/com/gitblit/wicket/WicketUtils.java
@@ -408,9 +408,10 @@ public class WicketUtils {
public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone) {
String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");
DateFormat df = new SimpleDateFormat(format);
- if (timeZone != null) {
- df.setTimeZone(timeZone);
+ if (timeZone == null) {
+ timeZone = GitBlit.getTimezone();
}
+ df.setTimeZone(timeZone);
String dateString;
if (date.getTime() == 0) {
dateString = "--";
@@ -438,9 +439,10 @@ public class WicketUtils {
public static Label createTimeLabel(String wicketId, Date date, TimeZone timeZone) {
String format = GitBlit.getString(Keys.web.timeFormat, "HH:mm");
DateFormat df = new SimpleDateFormat(format);
- if (timeZone != null) {
- df.setTimeZone(timeZone);
+ if (timeZone == null) {
+ timeZone = GitBlit.getTimezone();
}
+ df.setTimeZone(timeZone);
String timeString;
if (date.getTime() == 0) {
timeString = "--";
@@ -449,7 +451,6 @@ public class WicketUtils {
}
String title = TimeUtils.timeAgo(date);
Label label = new Label(wicketId, timeString);
- WicketUtils.setCssClass(label, TimeUtils.timeAgoCss(date));
if (!StringUtils.isEmpty(title)) {
WicketUtils.setHtmlTooltip(label, title);
}
@@ -459,9 +460,10 @@ public class WicketUtils {
public static Label createDatestampLabel(String wicketId, Date date, TimeZone timeZone) {
String format = GitBlit.getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy");
DateFormat df = new SimpleDateFormat(format);
- if (timeZone != null) {
- df.setTimeZone(timeZone);
+ if (timeZone == null) {
+ timeZone = GitBlit.getTimezone();
}
+ df.setTimeZone(timeZone);
String dateString;
if (date.getTime() == 0) {
dateString = "--";
@@ -483,7 +485,6 @@ public class WicketUtils {
title = tmp;
}
Label label = new Label(wicketId, dateString);
- WicketUtils.setCssClass(label, TimeUtils.timeAgoCss(date));
if (!StringUtils.isEmpty(title)) {
WicketUtils.setHtmlTooltip(label, title);
}
@@ -494,9 +495,10 @@ public class WicketUtils {
String format = GitBlit.getString(Keys.web.datetimestampLongFormat,
"EEEE, MMMM d, yyyy HH:mm Z");
DateFormat df = new SimpleDateFormat(format);
- if (timeZone != null) {
- df.setTimeZone(timeZone);
+ if (timeZone == null) {
+ timeZone = GitBlit.getTimezone();
}
+ df.setTimeZone(timeZone);
String dateString;
if (date.getTime() == 0) {
dateString = "--";
diff --git a/src/com/gitblit/wicket/pages/BasePage.java b/src/com/gitblit/wicket/pages/BasePage.java
index 515e9ce1..3852818a 100644
--- a/src/com/gitblit/wicket/pages/BasePage.java
+++ b/src/com/gitblit/wicket/pages/BasePage.java
@@ -181,7 +181,7 @@ public abstract class BasePage extends WebPage {
protected TimeZone getTimeZone() {
return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()
- .getTimezone() : TimeZone.getDefault();
+ .getTimezone() : GitBlit.getTimezone();
}
protected String getServerName() {
diff --git a/src/com/gitblit/wicket/panels/BasePanel.java b/src/com/gitblit/wicket/panels/BasePanel.java
index 73e13991..3606dd04 100644
--- a/src/com/gitblit/wicket/panels/BasePanel.java
+++ b/src/com/gitblit/wicket/panels/BasePanel.java
@@ -38,7 +38,7 @@ public abstract class BasePanel extends Panel {
protected TimeZone getTimeZone() {
return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()
- .getTimezone() : TimeZone.getDefault();
+ .getTimezone() : GitBlit.getTimezone();
}
protected void setPersonSearchTooltip(Component component, String value, Constants.SearchType searchType) {