mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-06-05 22:19:17 +02:00
properly handle daylight savings
This commit is contained in:
@ -48,7 +48,11 @@ fun getMSTillNextMinute(): Long {
|
||||
|
||||
fun getPassedSeconds(): Int {
|
||||
val calendar = Calendar.getInstance()
|
||||
val offset = calendar.timeZone.rawOffset
|
||||
val isDaylightSavingActive = TimeZone.getDefault().inDaylightTime(Date())
|
||||
var offset = calendar.timeZone.rawOffset
|
||||
if (isDaylightSavingActive) {
|
||||
offset += TimeZone.getDefault().dstSavings
|
||||
}
|
||||
return ((calendar.timeInMillis + offset) / 1000).toInt()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user