medtronic-0.11.7-SNAPSHOT
- fixed problem with dates (1 month shift)
This commit is contained in:
parent
f0b8aefc14
commit
deaa859d57
2 changed files with 24 additions and 43 deletions
|
@ -105,7 +105,7 @@ android {
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
versionCode 1500
|
versionCode 1500
|
||||||
// dev_version: 2.3.1-dev
|
// dev_version: 2.3.1-dev
|
||||||
version "medtronic-0.11.6-SNAPSHOT"
|
version "medtronic-0.11.7-SNAPSHOT"
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||||
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
@ -82,7 +81,7 @@ public class DateTimeUtil {
|
||||||
int second = (int) atechDateTime;
|
int second = (int) atechDateTime;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute, second);
|
return new GregorianCalendar(year, month - 1, dayOfMonth, hourOfDay, minute, second);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
if (L.isEnabled(L.PUMPCOMM))
|
||||||
LOG.error("DateTimeUtil", String.format("Error creating GregorianCalendar from values [atechDateTime=%d, year=%d, month=%d, day=%d, hour=%d, minute=%d, second=%d]", atechDateTime, year, month, dayOfMonth, hourOfDay, minute, second));
|
LOG.error("DateTimeUtil", String.format("Error creating GregorianCalendar from values [atechDateTime=%d, year=%d, month=%d, day=%d, hour=%d, minute=%d, second=%d]", atechDateTime, year, month, dayOfMonth, hourOfDay, minute, second));
|
||||||
|
@ -153,19 +152,19 @@ public class DateTimeUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static long toATechDate(Date date) {
|
// public static long toATechDate(Date date) {
|
||||||
|
//
|
||||||
long atechDateTime = 0L;
|
// long atechDateTime = 0L;
|
||||||
|
//
|
||||||
atechDateTime += (date.getYear() + 1900) * 10000000000L;
|
// atechDateTime += (date.getYear() + 1900) * 10000000000L;
|
||||||
atechDateTime += (date.getMonth() + 1) * 100000000L;
|
// atechDateTime += (date.getMonth() + 1) * 100000000L;
|
||||||
atechDateTime += date.getDate() * 1000000L;
|
// atechDateTime += date.getDate() * 1000000L;
|
||||||
atechDateTime += date.getHours() * 10000L;
|
// atechDateTime += date.getHours() * 10000L;
|
||||||
atechDateTime += date.getMinutes() * 100L;
|
// atechDateTime += date.getMinutes() * 100L;
|
||||||
atechDateTime += date.getSeconds();
|
// atechDateTime += date.getSeconds();
|
||||||
|
//
|
||||||
return atechDateTime;
|
// return atechDateTime;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public static String toString(long atechDateTime) {
|
public static String toString(long atechDateTime) {
|
||||||
|
@ -200,6 +199,7 @@ public class DateTimeUtil {
|
||||||
+ getZeroPrefixed(gc.get(Calendar.SECOND));
|
+ getZeroPrefixed(gc.get(Calendar.SECOND));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String toStringFromTimeInMillis(long timeInMillis) {
|
public static String toStringFromTimeInMillis(long timeInMillis) {
|
||||||
|
|
||||||
GregorianCalendar gc = new GregorianCalendar();
|
GregorianCalendar gc = new GregorianCalendar();
|
||||||
|
@ -208,6 +208,7 @@ public class DateTimeUtil {
|
||||||
return toString(gc);
|
return toString(gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getZeroPrefixed(int number) {
|
private static String getZeroPrefixed(int number) {
|
||||||
return (number < 10) ? "0" + number : "" + number;
|
return (number < 10) ? "0" + number : "" + number;
|
||||||
}
|
}
|
||||||
|
@ -224,9 +225,11 @@ public class DateTimeUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isSameDayATDAndMillis(long atechDateTime, long date) {
|
public static boolean isSameDayATDAndMillis(long atechDateTime, long timeInMillis) {
|
||||||
|
|
||||||
|
GregorianCalendar dt = new GregorianCalendar();
|
||||||
|
dt.setTimeInMillis(timeInMillis);
|
||||||
|
|
||||||
Date dt = new Date(date);
|
|
||||||
long entryDate = toATechDate(dt);
|
long entryDate = toATechDate(dt);
|
||||||
|
|
||||||
return (isSameDay(atechDateTime, entryDate));
|
return (isSameDay(atechDateTime, entryDate));
|
||||||
|
@ -235,34 +238,12 @@ public class DateTimeUtil {
|
||||||
|
|
||||||
public static long toMillisFromATD(long atechDateTime) {
|
public static long toMillisFromATD(long atechDateTime) {
|
||||||
|
|
||||||
int year = (int) (atechDateTime / 10000000000L);
|
GregorianCalendar gc = toGregorianCalendar(atechDateTime);
|
||||||
atechDateTime -= year * 10000000000L;
|
|
||||||
|
|
||||||
int month = (int) (atechDateTime / 100000000L);
|
return gc.getTimeInMillis();
|
||||||
atechDateTime -= month * 100000000L;
|
|
||||||
|
|
||||||
int dayOfMonth = (int) (atechDateTime / 1000000L);
|
|
||||||
atechDateTime -= dayOfMonth * 1000000L;
|
|
||||||
|
|
||||||
int hourOfDay = (int) (atechDateTime / 10000L);
|
|
||||||
atechDateTime -= hourOfDay * 10000L;
|
|
||||||
|
|
||||||
int minute = (int) (atechDateTime / 100L);
|
|
||||||
atechDateTime -= minute * 100L;
|
|
||||||
|
|
||||||
int second = (int) atechDateTime;
|
|
||||||
|
|
||||||
Date d = new Date();
|
|
||||||
d.setDate(dayOfMonth);
|
|
||||||
d.setMonth(month - 1);
|
|
||||||
d.setYear(year - 1900);
|
|
||||||
d.setHours(hourOfDay);
|
|
||||||
d.setMinutes(minute);
|
|
||||||
d.setSeconds(second);
|
|
||||||
|
|
||||||
return d.getTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int getATechDateDiferenceAsMinutes(Long date1, Long date2) {
|
public static int getATechDateDiferenceAsMinutes(Long date1, Long date2) {
|
||||||
|
|
||||||
Minutes minutes = Minutes.minutesBetween(toLocalDateTime(date1), toLocalDateTime(date2));
|
Minutes minutes = Minutes.minutesBetween(toLocalDateTime(date1), toLocalDateTime(date2));
|
||||||
|
|
Loading…
Reference in a new issue