Changeset 1432
- Timestamp:
- 01/19/10 09:11:52 (8 months ago)
- Location:
- tupper/trunk/tupper-site/src/main/java/org/kauriproject/tupper/resource
- Files:
-
- 3 modified
-
CalendarUtil.java (modified) (2 diffs)
-
InvoiceResource.java (modified) (1 diff)
-
RawDataResource.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tupper/trunk/tupper-site/src/main/java/org/kauriproject/tupper/resource/CalendarUtil.java
r1428 r1432 13 13 private static final Pattern WEEK_RANGE = Pattern.compile("^" + WEEK_PATTERN_STRING + "-" + WEEK_PATTERN_STRING + "$"); 14 14 15 public static Locale CALENDAR_LOCALE = new Locale("nl", "BE"); 16 15 17 public static Calendar getCalendar() { 16 18 // The firstDayOfWeek and minimalDaysInFirstWeek fields 17 19 // are dependent on the Locale, we use the Belgian settings 18 return new GregorianCalendar( new Locale("nl", "BE"));20 return new GregorianCalendar(CALENDAR_LOCALE); 19 21 } 20 22 … … 89 91 return new int[] {startWeek, startYear, endWeek, endYear}; 90 92 } 93 94 public static int[] getWeekAndYear(Calendar calendar) { 95 int year = calendar.get(YEAR); 96 int week = calendar.get(WEEK_OF_YEAR); 97 98 // At the beginning of the year, the day might fall in the last week of 99 // last year, while the year value would point to the new year. 100 // We adjust by letting the year value match the week. 101 // (see getCalendar(week, year) for similar problem) 102 if (calendar.get(MONTH) == JANUARY && week > 50) { 103 year--; 104 } 105 106 return new int[] {week, year}; 107 } 108 109 public static long getWeekIndex(int week, int year) { 110 return Long.parseLong(String.valueOf(year) + (week < 10 ? "0" + week : week)); 111 } 112 91 113 } -
tupper/trunk/tupper-site/src/main/java/org/kauriproject/tupper/resource/InvoiceResource.java
r1419 r1432 63 63 DateTime to = iso8601.parseDateTime((String) getRequest().getAttributes().get("to")); 64 64 65 Calendar cal = CalendarUtil.getCalendar(); 66 cal.setTime(from.toDate()); 67 templateData.put("beginWeek", cal.get(Calendar.WEEK_OF_YEAR)); 68 long beginIndex = Long.parseLong("" + cal.get(Calendar.YEAR) + "" + (cal.get(Calendar.WEEK_OF_YEAR) < 10 ? "0" + cal.get(Calendar.WEEK_OF_YEAR) : cal.get(Calendar.WEEK_OF_YEAR))); 69 cal.setTime(to.toDate()); 70 templateData.put("endWeek", cal.get(Calendar.WEEK_OF_YEAR)); 71 long endIndex = Long.parseLong("" + cal.get(Calendar.YEAR) + "" + (cal.get(Calendar.WEEK_OF_YEAR) < 10 ? "0" + cal.get(Calendar.WEEK_OF_YEAR) : cal.get(Calendar.WEEK_OF_YEAR))); 65 int[] fromWY = CalendarUtil.getWeekAndYear(from.toCalendar(CalendarUtil.CALENDAR_LOCALE)); 66 int[] toWY = CalendarUtil.getWeekAndYear(to.toCalendar(CalendarUtil.CALENDAR_LOCALE)); 67 68 long beginIndex = CalendarUtil.getWeekIndex(fromWY[0], fromWY[1]); 69 long endIndex = CalendarUtil.getWeekIndex(toWY[0], toWY[1]); 72 70 73 71 Form form = getRequest().getResourceRef().getQueryAsForm(); -
tupper/trunk/tupper-site/src/main/java/org/kauriproject/tupper/resource/RawDataResource.java
r1419 r1432 5 5 package org.kauriproject.tupper.resource; 6 6 7 import java.util.ArrayList;8 7 import java.util.Calendar; 9 import java.util.GregorianCalendar;10 8 import java.util.List; 11 9 import org.kauriproject.tupper.api.Tupper; … … 58 56 DateTime to = iso8601.parseDateTime((String) getRequest().getAttributes().get("to")); 59 57 60 Calendar calendar = CalendarUtil.getCalendar();61 calendar.setTime(from.toDate());62 long beginweek = Long.parseLong("" + calendar.get(GregorianCalendar.YEAR) + calendar.get(GregorianCalendar.WEEK_OF_YEAR)); 63 calendar.setTime(to.toDate());64 long endweek = Long.parseLong("" + calendar.get(GregorianCalendar.YEAR) + calendar.get(GregorianCalendar.WEEK_OF_YEAR));58 int[] fromWY = CalendarUtil.getWeekAndYear(from.toCalendar(CalendarUtil.CALENDAR_LOCALE)); 59 int[] toWY = CalendarUtil.getWeekAndYear(to.toCalendar(CalendarUtil.CALENDAR_LOCALE)); 60 61 long beginweek = CalendarUtil.getWeekIndex(fromWY[0], fromWY[1]); 62 long endweek = CalendarUtil.getWeekIndex(toWY[0], toWY[1]); 65 63 66 64 Form form = getRequest().getResourceRef().getQueryAsForm(); … … 68 66 String projectId = form.getValues("proj"); 69 67 String custInitials = form.getValues("cust"); 70 List<Performance> performances = new ArrayList<Performance>();68 List<Performance> performances; 71 69 72 70 try {