# [JGIT PATCH] Expose the raw timezone offset from PersonIdent

3 messages from 2008-09-05 to 2008-09-06. Participants: Shawn O. Pearce, Robin Rosenberg.
Thread: https://gitlist.dev/t/15378

## Shawn O. Pearce, 2008-09-05 01:37

Subject: [JGIT PATCH] Expose the raw timezone offset from PersonIdent
Message-ID: <1220578639-11723-1-git-send-email-spearce@spearce.org>
URL: https://gitlist.dev/e/1220578639-11723-1-git-send-email-spearce%40spearce.org

```
Applications may wish to have this value, much as they
can get the raw seconds-since-epoch and reformat it
for their own uses.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/lib/PersonIdent.java      |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java
index 5e524d3..bc5479a 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java
@@ -260,6 +260,14 @@ public TimeZone getTimeZone() {
 		return TimeZone.getTimeZone(ids[0]);
 	}
 
+	/**
+	 * @return this person's preferred time zone as minutes east of UTC. If the
+	 *         timezone is to the west of UTC it is negative.
+	 */
+	public int getTimeZoneOffset() {
+		return tzOffset;
+	}
+
 	public int hashCode() {
 		return getEmailAddress().hashCode() ^ (int) when;
 	}
-- 
1.6.0.1.319.g9f32b

```

## Robin Rosenberg, 2008-09-06 15:05

Subject: Re: [JGIT PATCH] Expose the raw timezone offset from PersonIdent
Message-ID: <200809061705.56879.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200809061705.56879.robin.rosenberg.lists%40dewire.com
In-Reply-To: <1220578639-11723-1-git-send-email-spearce@spearce.org>

```
fredagen den 5 september 2008 03.37.19 skrev Shawn O. Pearce:
> Applications may wish to have this value, much as they
> can get the raw seconds-since-epoch and reformat it
> for their own uses.

Necessary (performance) or just nice? We already provide the
timezone in java.util format.

-- robin

```

## Shawn O. Pearce, 2008-09-06 19:27

Subject: Re: [JGIT PATCH] Expose the raw timezone offset from PersonIdent
Message-ID: <20080906192727.GC18631@spearce.org>
URL: https://gitlist.dev/e/20080906192727.GC18631%40spearce.org
In-Reply-To: <200809061705.56879.robin.rosenberg.lists@dewire.com>

```
Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:
> fredagen den 5 september 2008 03.37.19 skrev Shawn O. Pearce:
> > Applications may wish to have this value, much as they
> > can get the raw seconds-since-epoch and reformat it
> > for their own uses.
> 
> Necessary (performance) or just nice? We already provide the
> timezone in java.util format.

It isn't necessary from a performance perspective, but is required
to read the commit data exactly, but in parsed form.

What I'm doing at the application level is taking a RevCommit and
converting it into a different data structure (more specifically
a Google Protocol Buffer) that has all of the parts broken out.
It looks like this:

  message GitPerson {
    required string name = 1;
    required string email = 2;
    required int32 when = 3;
    required int32 tz = 4;
  }
  
  message GitCommit {
    required string id = 1;
    repeated string parent_id = 2;
    required GitPerson author = 3;
    optional GitPerson committer = 4;
    optional string message = 5;
  }

I'm later processing the GitPerson in Python and need to use the tz
to offset when to format a time for display.  If the author has a
"funny" offset in their commit our existing getTimeZone() method
can return null, which means I have to then lie and send 0 to the
Python code.  I'd rather send the exact offset.

-- 
Shawn.

```
