Browse files

Issue 1195 fix accounting for DST when target time DST status differs…

… from now

git-svn-id: http://zxing.googlecode.com/svn/trunk@2216 59b500cc-1b3d-0410-9834-0bbf25fbcc57
  • Loading branch information...
1 parent d707744 commit bb443abde6c1e18d2863bc395d90a94c5698e25c srowen committed Mar 3, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 android/src/com/google/zxing/client/android/result/CalendarResultHandler.java
View
8 android/src/com/google/zxing/client/android/result/CalendarResultHandler.java
@@ -113,8 +113,12 @@ private static void appendTime(String when, StringBuilder result, boolean end, b
long milliseconds = date.getTime();
if (when.length() == 16 && when.charAt(15) == 'Z') {
Calendar calendar = new GregorianCalendar();
- int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
- milliseconds += offset;
+ // Account for time zone difference
+ milliseconds += calendar.get(Calendar.ZONE_OFFSET);
+ // Might need to correct for daylight savings time, but use target time since
+ // now might be in DST but not then, or vice versa
+ calendar.setTime(new Date(milliseconds));
+ milliseconds += calendar.get(Calendar.DST_OFFSET);
}
ParsedResult.maybeAppend(DateFormat.getDateTimeInstance().format(milliseconds), result);
}

0 comments on commit bb443ab

Please sign in to comment.