forked from penguin86/luna-tracker
MainActivity: use System.currentTimeMillis
A little better way to get the ms since epoch.
This commit is contained in:
@@ -454,7 +454,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
var duration = event.quantity
|
var duration = event.quantity
|
||||||
|
|
||||||
fun isValidTime(timeSeconds: Long, durationSeconds: Int): Boolean {
|
fun isValidTime(timeSeconds: Long, durationSeconds: Int): Boolean {
|
||||||
val now = Calendar.getInstance().time.time / 1000
|
val now = System.currentTimeMillis() / 1000
|
||||||
return (timeSeconds + durationSeconds) <= now && durationSeconds < (12 * 60 * 60)
|
return (timeSeconds + durationSeconds) <= now && durationSeconds < (12 * 60 * 60)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
durationPlus5Button.setOnClickListener { adjust(5) }
|
durationPlus5Button.setOnClickListener { adjust(5) }
|
||||||
|
|
||||||
durationNowButton.setOnClickListener {
|
durationNowButton.setOnClickListener {
|
||||||
val now = Calendar.getInstance().time.time / 1000
|
val now = System.currentTimeMillis() / 1000
|
||||||
val start = pickedDateTime.time.time / 1000
|
val start = pickedDateTime.time.time / 1000
|
||||||
if (now > start) {
|
if (now > start) {
|
||||||
duration = (now - start).toInt()
|
duration = (now - start).toInt()
|
||||||
|
|||||||
Reference in New Issue
Block a user