mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-14 04:58:52 -06:00
Limit to ScrollableChart not to go beyond 1970
This commit is contained in:
@@ -198,6 +198,17 @@ abstract class DateUtils {
|
||||
|
||||
return freq
|
||||
}
|
||||
@JvmStatic
|
||||
fun getMonthsSince1970(today: GregorianCalendar): Int {
|
||||
val start = GregorianCalendar(TimeZone.getTimeZone("GMT"))
|
||||
start.set(1970, Calendar.JANUARY, 1, 0, 0, 0)
|
||||
start.set(Calendar.MILLISECOND, 0)
|
||||
|
||||
val years = today.get(Calendar.YEAR) - start.get(Calendar.YEAR) - 2
|
||||
val months = today.get(Calendar.MONTH) - start.get(Calendar.MONTH)
|
||||
|
||||
return years * 12 + months
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getToday(): Timestamp = Timestamp(getStartOfToday())
|
||||
|
||||
Reference in New Issue
Block a user