Remove URGENCY_NEXT_MONTH

pull/996/head
Alex Baker 5 years ago
parent 9858a57d33
commit d045c75ff2

@ -7,13 +7,11 @@
package com.todoroo.andlib.utility;
import static androidx.test.InstrumentationRegistry.getTargetContext;
import static com.todoroo.andlib.utility.DateUtilities.addCalendarMonthsToUnixtime;
import static com.todoroo.andlib.utility.DateUtilities.getDateString;
import static com.todoroo.andlib.utility.DateUtilities.getStartOfDay;
import static com.todoroo.andlib.utility.DateUtilities.getTimeString;
import static com.todoroo.andlib.utility.DateUtilities.getWeekday;
import static com.todoroo.andlib.utility.DateUtilities.getWeekdayShort;
import static com.todoroo.andlib.utility.DateUtilities.oneMonthFromNow;
import static junit.framework.Assert.assertEquals;
import static org.tasks.Freeze.freezeAt;
import static org.tasks.date.DateTimeUtils.newDate;
@ -144,76 +142,6 @@ public class DateUtilitiesTest {
});
}
@Test
public void testOneMonthFromStartOfDecember() {
DateTime now = new DateTime(2013, 12, 1, 12, 19, 45, 192);
final long expected = new DateTime(2014, 1, 1, 12, 19, 45, 192).getMillis();
freezeAt(now)
.thawAfter(
new Snippet() {
{
assertEquals(expected, oneMonthFromNow());
}
});
}
@Test
public void testOneMonthFromEndOfDecember() {
DateTime now = new DateTime(2013, 12, 31, 16, 31, 20, 597);
final long expected = new DateTime(2014, 1, 31, 16, 31, 20, 597).getMillis();
freezeAt(now)
.thawAfter(
new Snippet() {
{
assertEquals(expected, oneMonthFromNow());
}
});
}
@Test
public void testGetSixMonthsFromEndOfDecember() {
final DateTime now = new DateTime(2013, 12, 31, 17, 17, 32, 900);
final long expected = new DateTime(2014, 7, 1, 17, 17, 32, 900).getMillis();
freezeAt(now)
.thawAfter(
new Snippet() {
{
assertEquals(expected, addCalendarMonthsToUnixtime(now.getMillis(), 6));
}
});
}
@Test
public void testOneMonthFromEndOfJanuary() {
DateTime now = new DateTime(2014, 1, 31, 12, 54, 33, 175);
final long expected = new DateTime(2014, 3, 3, 12, 54, 33, 175).getMillis();
freezeAt(now)
.thawAfter(
new Snippet() {
{
assertEquals(expected, oneMonthFromNow());
}
});
}
@Test
public void testOneMonthFromEndOfFebruary() {
DateTime now = new DateTime(2014, 2, 28, 9, 19, 7, 990);
final long expected = new DateTime(2014, 3, 28, 9, 19, 7, 990).getMillis();
freezeAt(now)
.thawAfter(
new Snippet() {
{
assertEquals(expected, oneMonthFromNow());
}
});
}
@Test
public void testShouldGetStartOfDay() {
DateTime now = new DateTime(2014, 1, 3, 10, 41, 41, 520);
@ -242,30 +170,6 @@ public class DateUtilitiesTest {
assertEquals("Sat", getWeekdayShort(newDate(2014, 1, 4)));
}
@Test
public void testAddMonthsToTimestamp() {
assertEquals(
newDate(2014, 1, 1).getMillis(),
addCalendarMonthsToUnixtime(newDate(2013, 12, 1).getMillis(), 1));
assertEquals(
newDate(2014, 12, 31).getMillis(),
addCalendarMonthsToUnixtime(newDate(2013, 12, 31).getMillis(), 12));
}
@Test
public void testAddMonthsWithLessDays() {
assertEquals(
newDate(2014, 3, 3).getMillis(),
addCalendarMonthsToUnixtime(newDate(2013, 12, 31).getMillis(), 2));
}
@Test
public void testAddMonthsWithMoreDays() {
assertEquals(
newDate(2014, 1, 30).getMillis(),
addCalendarMonthsToUnixtime(newDate(2013, 11, 30).getMillis(), 2));
}
@Test
public void usDateNoYear() {
setLocale(Locale.US);

@ -2,7 +2,6 @@ package com.todoroo.astrid.data;
import static com.todoroo.astrid.data.Task.URGENCY_DAY_AFTER;
import static com.todoroo.astrid.data.Task.URGENCY_IN_TWO_WEEKS;
import static com.todoroo.astrid.data.Task.URGENCY_NEXT_MONTH;
import static com.todoroo.astrid.data.Task.URGENCY_NEXT_WEEK;
import static com.todoroo.astrid.data.Task.URGENCY_NONE;
import static com.todoroo.astrid.data.Task.URGENCY_SPECIFIC_DAY;
@ -81,12 +80,6 @@ public class TaskTest {
assertEquals(expected, createDueDate(URGENCY_IN_TWO_WEEKS, -1L));
}
@Test
public void testCreateDueDateNextMonth() {
long expected = new DateTime(2014, 1, 31, 12, 0, 0, 0).getMillis();
assertEquals(expected, createDueDate(URGENCY_NEXT_MONTH, -1L));
}
@Test
public void testRemoveTimeForSpecificDay() {
long expected =

@ -36,25 +36,6 @@ public class DateUtilities {
private static final String ZH_YEAR = "yy\u5E74 " + ZH;
static Boolean is24HourOverride = null;
/**
* Add the specified amount of months to the given time.<br>
* The day of month will stay the same.<br>
*
* @param time the base-time (in milliseconds) to which the amount of months is added
* @param interval the amount of months to be added
* @return the calculated time in milliseconds
*/
public static long addCalendarMonthsToUnixtime(long time, int interval) {
DateTime dt = new DateTime(time);
DateTime result = dt.plusMonths(interval);
// preserving java.util.date behavior
int diff = dt.getDayOfMonth() - result.getDayOfMonth();
if (diff > 0) {
result = result.plusDays(diff);
}
return result.getMillis();
}
/** Returns unixtime for current time */
public static long now() {
return currentTimeMillis();
@ -64,11 +45,6 @@ public class DateUtilities {
* =========================================================== formatters
* ====================================================================== */
/** Returns unixtime one month from now */
public static long oneMonthFromNow() {
return addCalendarMonthsToUnixtime(currentTimeMillis(), 1);
}
public static boolean is24HourFormat(Context context) {
if (is24HourOverride != null) {
return is24HourOverride;

@ -115,7 +115,6 @@ public class Task implements Parcelable {
static final int URGENCY_DAY_AFTER = 3;
static final int URGENCY_NEXT_WEEK = 4;
static final int URGENCY_IN_TWO_WEEKS = 5;
static final int URGENCY_NEXT_MONTH = 6;
/** ID */
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
@ -284,9 +283,6 @@ public class Task implements Parcelable {
case URGENCY_IN_TWO_WEEKS:
date = DateUtilities.now() + 2 * DateUtilities.ONE_WEEK;
break;
case URGENCY_NEXT_MONTH:
date = DateUtilities.oneMonthFromNow();
break;
case URGENCY_SPECIFIC_DAY:
case URGENCY_SPECIFIC_DAY_TIME:
date = customDate;

Loading…
Cancel
Save