Search in sources :

Example 6 with Date

use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.

the class EventDatePickerDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View view = LayoutInflater.from(getThemedContext()).inflate(R.layout.dialog_birthday_picker, null, false);
    datePicker = Views.findById(view, R.id.dialog_birthday_picker);
    final EventType eventType = getEventType();
    if (initialDate.isPresent()) {
        datePicker.setDisplayingDate(initialDate.get());
    }
    return new AlertDialog.Builder(getActivity()).setTitle(eventType.getEventName(strings)).setView(view).setPositiveButton(R.string.birthday_picker_dialog_positive, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Date date = datePicker.getDisplayingDate();
            listener.onDatePicked(eventType, date);
        }
    }).create();
}
Also used : EventType(com.alexstyl.specialdates.events.peopleevents.EventType) StandardEventType(com.alexstyl.specialdates.events.peopleevents.StandardEventType) DialogInterface(android.content.DialogInterface) View(android.view.View) Date(com.alexstyl.specialdates.date.Date)

Example 7 with Date

use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.

the class DateTest method whenAddingADayOfMonth_thenIncreaseNormally.

@Test
public void whenAddingADayOfMonth_thenIncreaseNormally() {
    Date after = ANY_DATE.addDay(1);
    int expectedDay = DAY + 1;
    assertThat(after.getDayOfMonth()).isEqualTo(expectedDay);
}
Also used : Date(com.alexstyl.specialdates.date.Date) Test(org.junit.Test)

Example 8 with Date

use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.

the class DateTest method testOneYearAhead.

@Test
public void testOneYearAhead() {
    Date firstDayOfYear = Date.Companion.on(1, JANUARY, 1990);
    Date secondDayOfYear = Date.Companion.on(1, JANUARY, 1991);
    assertThat(firstDayOfYear.daysDifferenceTo(secondDayOfYear)).isEqualTo(365);
}
Also used : Date(com.alexstyl.specialdates.date.Date) Test(org.junit.Test)

Example 9 with Date

use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.

the class DateTest method givenDateWithShortMonthAndCommonYear_thenReturn28Days.

@Test
public void givenDateWithShortMonthAndCommonYear_thenReturn28Days() {
    Date date = Date.Companion.on(1, FEBRUARY, 2018);
    assertThat(date.getDaysInCurrentMonth()).isEqualTo(28);
}
Also used : Date(com.alexstyl.specialdates.date.Date) Test(org.junit.Test)

Example 10 with Date

use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.

the class DateTest method testTwoYearAhead.

@Test
public void testTwoYearAhead() {
    Date firstDayOfYear = Date.Companion.on(1, JANUARY, 1990);
    Date secondDayOfYear = Date.Companion.on(1, JANUARY, 1992);
    assertThat(firstDayOfYear.daysDifferenceTo(secondDayOfYear)).isEqualTo(365 * 2);
}
Also used : Date(com.alexstyl.specialdates.date.Date) Test(org.junit.Test)

Aggregations

Date (com.alexstyl.specialdates.date.Date)53 Test (org.junit.Test)34 ContactEvent (com.alexstyl.specialdates.date.ContactEvent)12 Contact (com.alexstyl.specialdates.contact.Contact)6 ContactEventsOnADate (com.alexstyl.specialdates.events.peopleevents.ContactEventsOnADate)6 ArrayList (java.util.ArrayList)4 View (android.view.View)3 Intent (android.content.Intent)2 RecyclerView (android.support.v7.widget.RecyclerView)2 TextView (android.widget.TextView)2 NamedayBundle (com.alexstyl.specialdates.events.namedays.NamedayBundle)2 NamedaysList (com.alexstyl.specialdates.events.namedays.NamedaysList)2 NamesInADate (com.alexstyl.specialdates.events.namedays.NamesInADate)2 Calendar (java.util.Calendar)2 DatePickerDialog (android.app.DatePickerDialog)1 PendingIntent (android.app.PendingIntent)1 DialogInterface (android.content.DialogInterface)1 Preference (android.preference.Preference)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RemoteViews (android.widget.RemoteViews)1