// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
//     private final DateTime mCurrentDateTime;
//     private static int mDaysOfYear = 0;
//     private static int mSemester;
// 
//     public StudentCalendar() {
//         mCurrentDateTime = new DateTime();
//         mDaysOfYear = getDaysOfYear();
// 
//         if (mCurrentDateTime.getMonthOfYear() >= 9) {
//             mSemester = 1;
//         } else {
//             mSemester = 2;
//         }
//     }
// 
//     public int getDayOfYear() {
//         int dayOfYear;
//         if (mCurrentDateTime.getMonthOfYear() >= 9) {
//             DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
//         } else {
//             DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
//         }
// 
//         return dayOfYear + 1;
//     }
// 
//     public int getDayOfYear(DateTime dateTime) {
//         int dayOfYear;
//         if (dateTime.getMonthOfYear() >= 9) {
//             DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
//         } else {
//             DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
//         }
//         return dayOfYear;
//     }
// 
//     public int getDaysOfYear() {
//         if (mDaysOfYear == 0) {
//             DateTime september;
//             DateTime august;
// 
//             if (mCurrentDateTime.getMonthOfYear() <= 8) {
//                 september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
//                 august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
//             } else {
//                 september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
//                 august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
//             }
// 
//             mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
//         }
//         return mDaysOfYear;
//     }
// 
//     public static int getWorkWeek(DateTime dateTime) {
//         DateTime september;
// 
//         if (dateTime.getMonthOfYear() <= 8) {
//             september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
//         }
// 
//         Interval interval = new Interval(september, dateTime);
//         int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
//         workWeek = workWeek == 0 ? 4 : workWeek;
//         return workWeek;
//     }
// 
//     public static DateTime convertToDefaultDateTime(int studentDay) {
//         DateTime september;
//         int currentMonth = DateTime.now().getMonthOfYear();
//         if (currentMonth <= 8) {
//             september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
//         }
//         return september.plusDays(studentDay - 1);
//     }
// 
//     public int getSemester() {
//         return mSemester;
//     }
// 
//     public static long getStartStudentYear() {
//         DateTime september;
// 
//         if (DateTime.now().getMonthOfYear() <= 8) {
//             september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
//         }
// 
//         return september.getMillis();
//     }
// 
//     public static long getEndStudentYear() {
//         DateTime august;
//         if (DateTime.now().getMonthOfYear() <= 8) {
//             august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
//         } else {
//             august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
//         }
//         return august.getMillis();
//     }
// 
// }


import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.DatePicker;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.Calendar;
import static android.app.DatePickerDialog.OnDateSetListener;
package ru.bsuirhelper.android.ui.schedule;




/**
 * Created by Влад on 07.11.13.
 */
public abstract class DialogDatePicker extends DialogFragment implements OnDateSetListener {
    private static final String SCHOOL_WEEK = "Учебная неделя ";

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
        CustomDatePicker datePickerDialog = new CustomDatePicker(getActivity(), this, year, month, day);
        if (Build.VERSION.SDK_INT > 10) {
// Path: app/src/ru/bsuirhelper/android/core/StudentCalendar.java
// public class StudentCalendar {
//     private final DateTime mCurrentDateTime;
//     private static int mDaysOfYear = 0;
//     private static int mSemester;
// 
//     public StudentCalendar() {
//         mCurrentDateTime = new DateTime();
//         mDaysOfYear = getDaysOfYear();
// 
//         if (mCurrentDateTime.getMonthOfYear() >= 9) {
//             mSemester = 1;
//         } else {
//             mSemester = 2;
//         }
//     }
// 
//     public int getDayOfYear() {
//         int dayOfYear;
//         if (mCurrentDateTime.getMonthOfYear() >= 9) {
//             DateTime september = new DateTime(mCurrentDateTime.getYear(), 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
//         } else {
//             DateTime september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, mCurrentDateTime).toPeriod(PeriodType.days()).getDays();
//         }
// 
//         return dayOfYear + 1;
//     }
// 
//     public int getDayOfYear(DateTime dateTime) {
//         int dayOfYear;
//         if (dateTime.getMonthOfYear() >= 9) {
//             DateTime september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
//         } else {
//             DateTime september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
//             dayOfYear = new Interval(september, dateTime).toPeriod(PeriodType.days()).getDays();
//         }
//         return dayOfYear;
//     }
// 
//     public int getDaysOfYear() {
//         if (mDaysOfYear == 0) {
//             DateTime september;
//             DateTime august;
// 
//             if (mCurrentDateTime.getMonthOfYear() <= 8) {
//                 september = new DateTime(mCurrentDateTime.getYear() - 1, 9, 1, 0, 0, 0);
//                 august = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
//             } else {
//                 september = new DateTime(mCurrentDateTime.getYear(), 8, 31, 0, 0, 0);
//                 august = new DateTime(mCurrentDateTime.getYear() + 1, 8, 31, 0, 0, 0);
//             }
// 
//             mDaysOfYear = new Interval(september, august).toPeriod(PeriodType.days()).getDays();
//         }
//         return mDaysOfYear;
//     }
// 
//     public static int getWorkWeek(DateTime dateTime) {
//         DateTime september;
// 
//         if (dateTime.getMonthOfYear() <= 8) {
//             september = new DateTime(dateTime.getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(dateTime.getYear(), 9, 1, 0, 0, 0);
//         }
// 
//         Interval interval = new Interval(september, dateTime);
//         int workWeek = (interval.toPeriod(PeriodType.weeks()).getWeeks() + 2) % 4;
//         workWeek = workWeek == 0 ? 4 : workWeek;
//         return workWeek;
//     }
// 
//     public static DateTime convertToDefaultDateTime(int studentDay) {
//         DateTime september;
//         int currentMonth = DateTime.now().getMonthOfYear();
//         if (currentMonth <= 8) {
//             september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(DateTime.now().getYear(), 9, 1, 0, 0, 0);
//         }
//         return september.plusDays(studentDay - 1);
//     }
// 
//     public int getSemester() {
//         return mSemester;
//     }
// 
//     public static long getStartStudentYear() {
//         DateTime september;
// 
//         if (DateTime.now().getMonthOfYear() <= 8) {
//             september = new DateTime(DateTime.now().getYear() - 1, 9, 1, 0, 0, 0);
//         } else {
//             september = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
//         }
// 
//         return september.getMillis();
//     }
// 
//     public static long getEndStudentYear() {
//         DateTime august;
//         if (DateTime.now().getMonthOfYear() <= 8) {
//             august = new DateTime(DateTime.now().getYear(), 8, 31, 1, 0, 0);
//         } else {
//             august = new DateTime(DateTime.now().getYear() + 1, 8, 31, 1, 0, 0);
//         }
//         return august.getMillis();
//     }
// 
// }


// Path: app/src/ru/bsuirhelper/android/ui/schedule/DialogDatePicker.java
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.DatePicker;
import org.joda.time.DateTime;
import ru.bsuirhelper.android.core.StudentCalendar;
import java.util.Calendar;
import static android.app.DatePickerDialog.OnDateSetListener;

package ru.bsuirhelper.android.ui.schedule;




/**
 * Created by Влад on 07.11.13.
 */
public abstract class DialogDatePicker extends DialogFragment implements OnDateSetListener {
    private static final String SCHOOL_WEEK = "Учебная неделя ";

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
        CustomDatePicker datePickerDialog = new CustomDatePicker(getActivity(), this, year, month, day);
        if (Build.VERSION.SDK_INT > 10) {
            datePickerDialog.getDatePicker().setMinDate(StudentCalendar.getStartStudentYear());