properly handle daylight savings

This commit is contained in:
tibbi
2018-03-14 09:43:37 +01:00
parent b3873e726c
commit b6e0d8381f
3 changed files with 14 additions and 5 deletions

View File

@ -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()
}