Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgChangelog.java @ 146:8c9f729f4dfa
Timezone finally in use
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 18 Feb 2011 05:20:18 +0100 |
parents | 144d771ee73c |
children | ab7ea2ac21cb |
comparison
equal
deleted
inserted
replaced
145:acc6151b1b7a | 146:8c9f729f4dfa |
---|---|
17 package org.tmatesoft.hg.repo; | 17 package org.tmatesoft.hg.repo; |
18 | 18 |
19 import java.io.UnsupportedEncodingException; | 19 import java.io.UnsupportedEncodingException; |
20 import java.util.ArrayList; | 20 import java.util.ArrayList; |
21 import java.util.Arrays; | 21 import java.util.Arrays; |
22 import java.util.Calendar; | |
22 import java.util.Collections; | 23 import java.util.Collections; |
23 import java.util.Date; | 24 import java.util.Date; |
24 import java.util.Formatter; | 25 import java.util.Formatter; |
25 import java.util.HashMap; | 26 import java.util.HashMap; |
26 import java.util.List; | 27 import java.util.List; |
27 import java.util.Locale; | 28 import java.util.Locale; |
28 import java.util.Map; | 29 import java.util.Map; |
30 import java.util.TimeZone; | |
29 | 31 |
30 import org.tmatesoft.hg.core.Nodeid; | 32 import org.tmatesoft.hg.core.Nodeid; |
31 import org.tmatesoft.hg.internal.RevlogStream; | 33 import org.tmatesoft.hg.internal.RevlogStream; |
32 | 34 |
33 | 35 |
104 private/* final */Nodeid manifest; | 106 private/* final */Nodeid manifest; |
105 private String user; | 107 private String user; |
106 private String comment; | 108 private String comment; |
107 private List<String> files; // unmodifiable collection (otherwise #files() and implicit #clone() shall be revised) | 109 private List<String> files; // unmodifiable collection (otherwise #files() and implicit #clone() shall be revised) |
108 private Date time; | 110 private Date time; |
109 private int timezone; // not sure it's of any use | 111 private int timezone; |
110 private Map<String, String> extras; | 112 private Map<String, String> extras; |
111 | 113 |
112 /** | 114 /** |
113 * @see mercurial/changelog.py:read() | 115 * @see mercurial/changelog.py:read() |
114 * | 116 * |
147 public Date date() { | 149 public Date date() { |
148 return time; | 150 return time; |
149 } | 151 } |
150 | 152 |
151 public String dateString() { | 153 public String dateString() { |
154 // XXX keep once formatted? Perhaps, there's faster way to set up calendar/time zone? | |
152 StringBuilder sb = new StringBuilder(30); | 155 StringBuilder sb = new StringBuilder(30); |
153 Formatter f = new Formatter(sb, Locale.US); | 156 Formatter f = new Formatter(sb, Locale.US); |
154 f.format("%ta %<tb %<td %<tH:%<tM:%<tS %<tY %<tz", time); | 157 TimeZone tz = TimeZone.getTimeZone("GMT"); |
158 // apparently timezone field records number of seconds time differs from UTC, | |
159 // i.e. value to substract from time to get UTC time. Calendar seems to add | |
160 // timezone offset to UTC, instead, hence sign change. | |
161 tz.setRawOffset(timezone * -1000); | |
162 Calendar c = Calendar.getInstance(tz, Locale.US); | |
163 c.setTime(time); | |
164 f.format("%ta %<tb %<td %<tH:%<tM:%<tS %<tY %<tz", c); | |
155 return sb.toString(); | 165 return sb.toString(); |
156 } | 166 } |
157 | 167 |
158 public Map<String, String> extras() { | 168 public Map<String, String> extras() { |
159 return extras; | 169 return extras; |