Skip to content

Commit

Permalink
fixed files form Time #9
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 8747336 commit 18d623f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions projects/Time/9/org/joda/time/DateTimeZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,19 @@ public static DateTimeZone forOffsetHoursMinutes(int hoursOffset, int minutesOff
if (hoursOffset == 0 && minutesOffset == 0) {
return DateTimeZone.UTC;
}
if (hoursOffset < -23 || hoursOffset > 23) {
throw new IllegalArgumentException("Hours out of range: " + hoursOffset);
}
if (minutesOffset < 0 || minutesOffset > 59) {
throw new IllegalArgumentException("Minutes out of range: " + minutesOffset);
}
int offset = 0;
try {
int hoursInMinutes = FieldUtils.safeMultiply(hoursOffset, 60);
int hoursInMinutes = hoursOffset * 60;
if (hoursInMinutes < 0) {
minutesOffset = FieldUtils.safeAdd(hoursInMinutes, -minutesOffset);
minutesOffset = hoursInMinutes - minutesOffset;
} else {
minutesOffset = FieldUtils.safeAdd(hoursInMinutes, minutesOffset);
minutesOffset = hoursInMinutes + minutesOffset;
}
offset = FieldUtils.safeMultiply(minutesOffset, DateTimeConstants.MILLIS_PER_MINUTE);
} catch (ArithmeticException ex) {
Expand All @@ -280,6 +283,9 @@ public static DateTimeZone forOffsetHoursMinutes(int hoursOffset, int minutesOff
* @return the DateTimeZone object for the offset
*/
public static DateTimeZone forOffsetMillis(int millisOffset) {
if (millisOffset < -MAX_MILLIS || millisOffset > MAX_MILLIS) {
throw new IllegalArgumentException("Millis out of range: " + millisOffset);
}
String id = printOffset(millisOffset);
return fixedOffsetZone(id, millisOffset);
}
Expand Down

0 comments on commit 18d623f

Please sign in to comment.