]> source.dussan.org Git - gitblit.git/commitdiff
Fixed date bugs on IssueModel
authorJames Moger <james.moger@gitblit.com>
Fri, 17 Feb 2012 23:42:35 +0000 (18:42 -0500)
committerJames Moger <james.moger@gitblit.com>
Fri, 17 Feb 2012 23:42:35 +0000 (18:42 -0500)
src/com/gitblit/models/IssueModel.java
src/com/gitblit/utils/JsonUtils.java

index 246b29bf05eb49d17baf0d729b17741c5ff8ace8..3c191e241b608c53107eac050dc6c6aa7c33e2b4 100644 (file)
@@ -59,7 +59,8 @@ public class IssueModel implements Serializable, Comparable<IssueModel> {
        public List<Change> changes;\r
 \r
        public IssueModel() {\r
-               created = new Date((System.currentTimeMillis() / 1000) * 1000);\r
+               // the first applied change set the date appropriately\r
+               created = new Date(0);\r
 \r
                type = Type.Defect;\r
                status = Status.New;\r
@@ -117,6 +118,10 @@ public class IssueModel implements Serializable, Comparable<IssueModel> {
        }\r
 \r
        public void applyChange(Change change) {\r
+               if (changes.size() == 0) {\r
+                       // first change created the issue\r
+                       created = change.created;\r
+               }\r
                changes.add(change);\r
 \r
                if (change.hasFieldChanges()) {\r
index aea46bbbe760026ef170b61b2ebc72ff0cc9f292..bc9a1e00f098ea1f72b72b28630074d9f9b40d3d 100644 (file)
@@ -295,7 +295,8 @@ public class JsonUtils {
                                JsonDeserializationContext jsonDeserializationContext) {\r
                        try {\r
                                synchronized (dateFormat) {\r
-                                       return dateFormat.parse(jsonElement.getAsString());\r
+                                       Date date = dateFormat.parse(jsonElement.getAsString());                                        \r
+                                       return new Date((date.getTime() / 1000) * 1000);\r
                                }\r
                        } catch (ParseException e) {\r
                                throw new JsonSyntaxException(jsonElement.getAsString(), e);\r