package com.prolificinteractive.materialcalendarview;

import java.util.Calendar;
import java.util.Date;

import static java.util.Calendar.DATE;
import static java.util.Calendar.DAY_OF_WEEK;
import static java.util.Calendar.MONTH;
import static java.util.Calendar.YEAR;

/**
 * Utilities for Calendar
 */
public class CalendarUtils {

    public static Calendar getInstance(Date date) {
        Calendar calendar = Calendar.getInstance();
        if(date != null) {
            calendar.setTime(date);
        }
        int year = getYear(calendar);
        int month = getMonth(calendar);
        int day = getDay(calendar);
        calendar.clear();
        calendar.set(year, month, day);
        return calendar;
    }

    public static Calendar getInstance() {
        Calendar calendar = Calendar.getInstance();
        copyDateTo(calendar, calendar);
        return calendar;
    }

    public static void setToFirstDay(Calendar calendar) {
        int year = getYear(calendar);
        int month = getMonth(calendar);
        calendar.clear();
        calendar.set(year, month, 1);
        calendar.getTimeInMillis();
    }

    public static void copyDateTo(Calendar from, Calendar to) {
        to.clear();
        to.set(
                getYear(from),
                getMonth(from),
                getDay(from)
        );
        to.setTimeZone(from.getTimeZone());
        to.getTimeInMillis();
    }

    public static int getYear(Calendar calendar) {
        return calendar.get(YEAR);
    }

    public static int getMonth(Calendar calendar) {
        return calendar.get(MONTH);
    }

    public static int getDay(Calendar calendar) {
        return calendar.get(DATE);
    }

    public static int getDayOfWeek(Calendar calendar) {
        return calendar.get(DAY_OF_WEEK);
    }
}

@@ -328,16 +328,129 @@
 tils %7B%0A%0A
+    /**%0A     * @return a new Calendar instance with the date set to the provided date. Time set to zero.%0A     */%0A
     publ
@@ -489,24 +489,24 @@
 ate date) %7B%0A
-
         Cale
@@ -822,32 +822,133 @@
 alendar;%0A    %7D%0A%0A
+    /**%0A     * @return a new Calendar instance with the date set to today. Time set to zero.%0A     */%0A
     public stati
@@ -1090,32 +1090,146 @@
 alendar;%0A    %7D%0A%0A
+    /**%0A     * Set the provided calendar to the first day of the month. Also clears all time information.%0A     */%0A
     public stati
@@ -1447,32 +1447,108 @@
 illis();%0A    %7D%0A%0A
+    /**%0A     * Copy %3Ci%3Eonly%3C/i%3E date information to a new calendar.%0A     */%0A
     public stati

Add documentation to CalendarUtils