package com.alamkanak.weekview;

import java.util.Calendar;

/**
 * Created by jesse on 6/02/2016.
 */
public class WeekViewUtil {


    /////////////////////////////////////////////////////////////////
    //
    //      Helper methods.
    //
    /////////////////////////////////////////////////////////////////

    /**
     * Checks if two times are on the same day.
     * @param dayOne The first day.
     * @param dayTwo The second day.
     * @return Whether the times are on the same day.
     */
    public static boolean isSameDay(Calendar dayOne, Calendar dayTwo) {
        return dayOne.get(Calendar.YEAR) == dayTwo.get(Calendar.YEAR) && dayOne.get(Calendar.DAY_OF_YEAR) == dayTwo.get(Calendar.DAY_OF_YEAR);
    }

    /**
     * Returns a calendar instance at the start of this day
     * @return the calendar instance
     */
    public static Calendar today(){
        Calendar today = Calendar.getInstance();
        today.set(Calendar.HOUR_OF_DAY, 0);
        today.set(Calendar.MINUTE, 0);
        today.set(Calendar.SECOND, 0);
        today.set(Calendar.MILLISECOND, 0);
        return today;
    }

    /**
     * Checks if two times are on the same day and hour.
     *
     * @param dayOne The first day.
     * @param dayTwo The second day.
     * @return Whether the times are on the same day and hour.
     */
    public static boolean isSameDayAndHour(Calendar dayOne, Calendar dayTwo) {

        if (dayTwo != null) {
            return dayOne.get(Calendar.YEAR) == dayTwo.get(Calendar.YEAR) && dayOne.get(Calendar.DAY_OF_YEAR) == dayTwo.get(Calendar.DAY_OF_YEAR) && dayOne.get(Calendar.HOUR_OF_DAY) == dayTwo.get(Calendar.HOUR_OF_DAY);
        }
        return false;
    }
}

@@ -330,35 +330,35 @@
 * Checks if two 
-tim
+dat
 es are on the sa
@@ -361,24 +361,31 @@
 e same day.%0A
+     *%0A
      * @para
@@ -380,33 +380,34 @@
      * @param da
-y
+te
 One The first da
@@ -398,33 +398,34 @@
 One The first da
-y
+te
 .%0A     * @param 
@@ -418,33 +418,34 @@
      * @param da
-y
+te
 Two The second d
@@ -437,34 +437,41 @@
 wo The second da
-y.
+te.     *
 %0A     * @return 
@@ -474,35 +474,35 @@
 urn Whether the 
-tim
+dat
 es are on the sa
@@ -556,33 +556,34 @@
 eDay(Calendar da
-y
+te
 One, Calendar da
@@ -578,25 +578,26 @@
  Calendar da
-y
+te
 Two) %7B%0A     
@@ -600,33 +600,34 @@
        return da
-y
+te
 One.get(Calendar
@@ -630,33 +630,34 @@
 ndar.YEAR) == da
-y
+te
 Two.get(Calendar
@@ -660,33 +660,34 @@
 ndar.YEAR) && da
-y
+te
 One.get(Calendar
@@ -697,33 +697,34 @@
 Y_OF_YEAR) == da
-y
+te
 Two.get(Calendar
@@ -809,15 +809,19 @@
 of t
-his day
+oday%0A     *
 %0A   
@@ -1171,19 +1171,19 @@
  if two 
-tim
+dat
 es are o
@@ -1230,17 +1230,18 @@
 param da
-y
+te
 One The 
@@ -1267,17 +1267,18 @@
 param da
-y
+te
 Two The 
@@ -1320,11 +1320,11 @@
 the 
-tim
+dat
 es a
@@ -1414,17 +1414,18 @@
 endar da
-y
+te
 One, Cal
@@ -1432,17 +1432,18 @@
 endar da
-y
+te
 Two) %7B%0A%0A
@@ -1456,17 +1456,18 @@
   if (da
-y
+te
 Two != n
@@ -1492,19 +1492,51 @@
  return 
-day
+isSameDay(dateOne, dateTwo) && date
 One.get(
@@ -1544,28 +1544,36 @@
 alendar.
-YEAR
+HOUR_OF_DAY
 ) == da
-y
+te
 Two.get(
@@ -1585,108 +1585,358 @@
 dar.
-YEAR) && dayOne.get(Calendar.DAY_OF_YEAR) == dayTwo.get(Calendar.DAY_OF_YEAR) && dayOne.get(
+HOUR_OF_DAY);%0A        %7D%0A        return false;%0A    %7D%0A%0A    /**%0A     * Returns the amount of days between the second date and the first date%0A     *%0A     * @param dateOne the first date%0A     * @param dateTwo the second date%0A     * @return the amount of days between dateTwo and dateOne%0A     */%0A    public static int daysBetween(Calendar dateOne, 
 Calendar
 .HOU
@@ -1935,58 +1935,147 @@
 ndar
-.HOUR_OF_DAY) == dayTwo.get(Calendar.HOUR_OF_DAY);
+ dateTwo)%7B%0A        return (int) (%0A                (dateTwo.getTimeInMillis() + dateTwo.getTimeZone().getOffset(dateTwo.getTimeInMillis()) -
 %0A   
@@ -2075,34 +2075,32 @@
 ) -%0A        
-%7D%0A
         
 return false
@@ -2083,34 +2083,161 @@
             
-return false
+(dateOne.getTimeInMillis() + dateOne.getTimeZone().getOffset(dateOne.getTimeInMillis())))%0A                        / (1000 * 60 * 60 * 24f))
 ;%0A    %7D%0A%7D%0A

Improve WeekViewUtil