dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32442
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16555: fix for tz gaps in ChronologyBasedCalendar
------------------------------------------------------------
revno: 16555
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-08-28 20:10:01 +0700
message:
fix for tz gaps in ChronologyBasedCalendar
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java 2014-05-21 11:12:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java 2014-08-28 13:10:01 +0000
@@ -68,6 +68,7 @@
DateTime dateTime = dateUnit.toDateTime( ISOChronology.getInstance() );
dateTime = dateTime.withChronology( chronology );
+
return DateUnit.fromDateTime( dateTime );
}
@@ -110,8 +111,7 @@
fromDateUnit.setDayOfWeek( isoWeekday( fromDateUnit ) );
toDateUnit.setDayOfWeek( isoWeekday( toDateUnit ) );
- return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ),
- DateIntervalType.ISO8601_YEAR );
+ return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ), DateIntervalType.ISO8601_YEAR );
}
private DateInterval toMonthIsoInterval( DateUnit dateUnit, int offset, int length )
@@ -135,8 +135,7 @@
fromDateUnit.setDayOfWeek( isoWeekday( fromDateUnit ) );
toDateUnit.setDayOfWeek( isoWeekday( toDateUnit ) );
- return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ),
- DateIntervalType.ISO8601_MONTH );
+ return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ), DateIntervalType.ISO8601_MONTH );
}
private DateInterval toWeekIsoInterval( DateUnit dateUnit, int offset, int length )
@@ -160,8 +159,7 @@
fromDateUnit.setDayOfWeek( isoWeekday( fromDateUnit ) );
toDateUnit.setDayOfWeek( isoWeekday( toDateUnit ) );
- return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ),
- DateIntervalType.ISO8601_WEEK );
+ return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ), DateIntervalType.ISO8601_WEEK );
}
private DateInterval toDayIsoInterval( DateUnit dateUnit, int offset, int length )
@@ -185,42 +183,41 @@
fromDateUnit.setDayOfWeek( isoWeekday( fromDateUnit ) );
toDateUnit.setDayOfWeek( isoWeekday( toDateUnit ) );
- return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ),
- DateIntervalType.ISO8601_DAY );
+ return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ), DateIntervalType.ISO8601_DAY );
}
@Override
public int monthsInYear()
{
- DateTime dateTime = new DateTime( 1, 1, 1, 0, 0, chronology );
+ DateTime dateTime = new DateTime( 1, 1, 1, 12, 0, chronology );
return dateTime.monthOfYear().getMaximumValue();
}
@Override
public int daysInWeek()
{
- DateTime dateTime = new DateTime( 1, 1, 1, 0, 0, chronology );
+ DateTime dateTime = new DateTime( 1, 1, 1, 12, 0, chronology );
return dateTime.dayOfWeek().getMaximumValue();
}
@Override
public int daysInYear( int year )
{
- DateTime dateTime = new DateTime( year, 1, 1, 0, 0, chronology );
+ DateTime dateTime = new DateTime( year, 1, 1, 12, 0, chronology );
return (int) dateTime.year().toInterval().toDuration().getStandardDays();
}
@Override
public int daysInMonth( int year, int month )
{
- DateTime dateTime = new DateTime( year, month, 1, 0, 0, chronology );
+ DateTime dateTime = new DateTime( year, month, 1, 12, 0, chronology );
return dateTime.dayOfMonth().getMaximumValue();
}
@Override
public int weeksInYear( int year )
{
- DateTime dateTime = new DateTime( year, 1, 1, 0, 0, chronology );
+ DateTime dateTime = new DateTime( year, 1, 1, 12, 0, chronology );
return dateTime.weekOfWeekyear().getMaximumValue();
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.java 2014-08-24 17:10:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.java 2014-08-28 13:10:01 +0000
@@ -184,7 +184,7 @@
throw new RuntimeException( "Cannot convert non-ISO8601 DateUnit to DateTime." );
}
- return new DateTime( year, month, day, 0, 0, ISOChronology.getInstance() );
+ return new DateTime( year, month, day, 12, 0, ISOChronology.getInstance() );
}
/**
@@ -195,7 +195,7 @@
*/
public DateTime toDateTime( Chronology chronology )
{
- return new DateTime( year, month, day, 0, 0, chronology );
+ return new DateTime( year, month, day, 12, 0, chronology );
}
/**