diff options
3 files changed, 17 insertions, 3 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java index b53dce2161..3daaea90c5 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java @@ -137,7 +137,11 @@ public class MockSystemReader extends SystemReader { @Override public int getTimezone(long when) { - return TimeZone.getTimeZone("GMT-03:30").getOffset(when) / (60 * 1000); + return getTimeZone().getOffset(when) / (60 * 1000); } + @Override + public TimeZone getTimeZone() { + return TimeZone.getTimeZone("GMT-03:30"); + } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index 4a92ea624f..6cc0093805 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -73,11 +73,12 @@ import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.notes.NoteMap; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevTree; +import org.eclipse.jgit.util.SystemReader; import org.kohsuke.args4j.Option; @Command(common = true, usage = "usage_viewCommitHistory") class Log extends RevWalkTextBuiltin { - private final TimeZone myTZ = TimeZone.getDefault(); + private final TimeZone myTZ = SystemReader.getInstance().getTimeZone(); private final DateFormat fmt; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java index ced1d90b8e..0b72ade50b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java @@ -118,7 +118,11 @@ public abstract class SystemReader { @Override public int getTimezone(long when) { - return TimeZone.getDefault().getOffset(when) / (60 * 1000); + return getTimeZone().getOffset(when) / (60 * 1000); + } + + public TimeZone getTimeZone() { + return TimeZone.getDefault(); } }; @@ -187,4 +191,9 @@ public abstract class SystemReader { * @return the local time zone */ public abstract int getTimezone(long when); + + /** + * @return system time zone, possibly mocked for testing + */ + public abstract TimeZone getTimeZone(); } |