Skip to content

Commit

Permalink
Date range
Browse files Browse the repository at this point in the history
  • Loading branch information
witek committed Aug 28, 2015
1 parent b94a95c commit d6edd30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<classpathentry exported="true" kind="lib" path="lib/velocity-1.7.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xmlbeans-2.6.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/javax.mail.jar"/>
<classpathentry exported="true" kind="lib" path="lib/httpclient-4.3.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xercesImpl-2.11.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xstream-1.4.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/gwt-dnd-3.3.0.jar"/>
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/ilarkesto/core/time/DateRange.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* Copyright 2011 Witoslaw Koczewsi <[email protected]>
*
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero
* General Public License as published by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License along with this program. If not,
* see <http://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -237,7 +237,14 @@ public boolean isOverlapping(DateRange other) {
}

public DateRange moveToYear(int year) {
return new DateRange(new Date(year, start.month, start.day), new Date(year, end.month, end.day));
Date newStart = new Date(year, start.month, start.day);
Date newEnd = new Date(year, end.month, end.day);
if (newEnd.isBefore(newStart)) newEnd = new Date(year + 1, end.month, end.day);
return new DateRange(newStart, newEnd);
}

public DateRange moveToYears(int startYear, int endYear) {
return new DateRange(new Date(startYear, start.month, start.day), new Date(endYear, end.month, end.day));
}

// --- creates ---
Expand Down

0 comments on commit d6edd30

Please sign in to comment.