mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Allow date to be fixed at a certain timestamp
This commit is contained in:
@@ -32,14 +32,22 @@ import java.util.TimeZone;
|
||||
public class DateHelper
|
||||
{
|
||||
public static int millisecondsInOneDay = 24 * 60 * 60 * 1000;
|
||||
private static Long fixedLocalTime = null;
|
||||
|
||||
public static long getLocalTime()
|
||||
{
|
||||
if(fixedLocalTime != null) return fixedLocalTime;
|
||||
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
long now = new Date().getTime();
|
||||
return now + tz.getOffset(now);
|
||||
}
|
||||
|
||||
public static void setFixedLocalTime(Long timestamp)
|
||||
{
|
||||
fixedLocalTime = timestamp;
|
||||
}
|
||||
|
||||
public static long toLocalTime(long timestamp)
|
||||
{
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
@@ -54,9 +62,7 @@ public class DateHelper
|
||||
|
||||
public static GregorianCalendar getStartOfTodayCalendar()
|
||||
{
|
||||
GregorianCalendar day = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
|
||||
day.setTimeInMillis(DateHelper.getStartOfDay(DateHelper.getLocalTime()));
|
||||
return day;
|
||||
return getCalendar(getStartOfToday());
|
||||
}
|
||||
|
||||
public static GregorianCalendar getCalendar(long timestamp)
|
||||
@@ -187,5 +193,4 @@ public class DateHelper
|
||||
|
||||
return weekday;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user