[Notice] Announcing the End of Demo Server [Read me]

move expandDueDate to JodaDateUtil
@9daf1fdcd8895d4236d516ea8b9f2d6da133e2d9
--- app/controllers/IssueApp.java
+++ app/controllers/IssueApp.java
... | ... | @@ -353,8 +353,7 @@ |
353 | 353 |
} |
354 | 354 |
|
355 | 355 |
if (issueMassUpdate.isDueDateChanged) { |
356 |
- issue.dueDate = issueMassUpdate.dueDate; |
|
357 |
- issue.expandDueDate(); |
|
356 |
+ issue.dueDate = JodaDateUtil.lastSecondOfDay(issueMassUpdate.dueDate); |
|
358 | 357 |
} |
359 | 358 |
|
360 | 359 |
issue.updatedDate = JodaDateUtil.now(); |
... | ... | @@ -413,7 +412,7 @@ |
413 | 412 |
addLabels(newIssue, request()); |
414 | 413 |
setMilestone(issueForm, newIssue); |
415 | 414 |
|
416 |
- newIssue.expandDueDate(); |
|
415 |
+ newIssue.dueDate = JodaDateUtil.lastSecondOfDay(newIssue.dueDate); |
|
417 | 416 |
newIssue.save(); |
418 | 417 |
|
419 | 418 |
attachUploadFilesToPost(newIssue.asResource()); |
... | ... | @@ -503,7 +502,7 @@ |
503 | 502 |
final Issue issue = issueForm.get(); |
504 | 503 |
removeAnonymousAssignee(issue); |
505 | 504 |
setMilestone(issueForm, issue); |
506 |
- issue.expandDueDate(); |
|
505 |
+ issue.dueDate = JodaDateUtil.lastSecondOfDay(issue.dueDate); |
|
507 | 506 |
|
508 | 507 |
final Issue originalIssue = Issue.findByNumber(project, number); |
509 | 508 |
|
--- app/models/Issue.java
+++ app/models/Issue.java
... | ... | @@ -157,14 +157,6 @@ |
157 | 157 |
} |
158 | 158 |
} |
159 | 159 |
|
160 |
- public void expandDueDate() { |
|
161 |
- if (dueDate != null) { |
|
162 |
- dueDate = DateUtils.setHours(dueDate, 23); |
|
163 |
- dueDate = DateUtils.setMinutes(dueDate, 59); |
|
164 |
- dueDate = DateUtils.setSeconds(dueDate, 59); |
|
165 |
- } |
|
166 |
- } |
|
167 |
- |
|
168 | 160 |
/** |
169 | 161 |
* @see #updateAssignee() |
170 | 162 |
*/ |
--- app/utils/JodaDateUtil.java
+++ app/utils/JodaDateUtil.java
... | ... | @@ -86,4 +86,17 @@ |
86 | 86 |
public static int localDaysBetween(Date from, Date to) { |
87 | 87 |
return Days.daysBetween(new DateTime(from).toLocalDate(), new DateTime(to).toLocalDate()).getDays(); |
88 | 88 |
} |
89 |
+ |
|
90 |
+ /** |
|
91 |
+ * Force update HH:mm:ss -> 23:59:59 |
|
92 |
+ */ |
|
93 |
+ public static Date lastSecondOfDay(Date date) { |
|
94 |
+ if (date == null) { |
|
95 |
+ return null; |
|
96 |
+ } |
|
97 |
+ DateTime dateTime = new DateTime(date); |
|
98 |
+ return dateTime.withField(DateTimeFieldType.hourOfDay(), 23) |
|
99 |
+ .withField(DateTimeFieldType.minuteOfHour(), 59) |
|
100 |
+ .withField(DateTimeFieldType.secondOfMinute(), 59).toDate(); |
|
101 |
+ } |
|
89 | 102 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?