Fixes timezone bug and arithmetic overflow

This commit is contained in:
2014-11-11 04:40:05 -05:00
parent 477eb80109
commit d8343105ec
2 changed files with 4 additions and 3 deletions

View File

@@ -231,8 +231,8 @@ public class ShowHabitsFragment extends Fragment implements OnSavedListener, OnI
listView.setOnTouchListener(controller);
listView.setDragEnabled(true);
GregorianCalendar day = new GregorianCalendar();
day.setTimeInMillis(DateHelper.getLocalTime());
GregorianCalendar day = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
day.setTimeInMillis(DateHelper.getStartOfDay(DateHelper.getLocalTime()));
for (int i = 0; i < button_count; i++)
{

View File

@@ -9,6 +9,7 @@ import org.isoron.uhabits.R;
import android.annotation.SuppressLint;
import android.graphics.Color;
import android.util.Log;
import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
@@ -258,7 +259,7 @@ public class Habit extends Model
public int[] getReps(long timeFrom, long timeTo)
{
long timeFromExtended = timeFrom - freq_den * DateHelper.millisecondsInOneDay;
long timeFromExtended = timeFrom - (long)(freq_den) * DateHelper.millisecondsInOneDay;
List<Repetition> reps = selectRepsFromTo(timeFromExtended, timeTo).execute();
int nDaysExtended = (int) ((timeTo - timeFromExtended) / DateHelper.millisecondsInOneDay);