Skip to content

Commit

Permalink
fix: support for daylight saving other than one hour
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Oct 28, 2024
1 parent 5746da1 commit b8b5b90
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
Binary file added app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file added app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
5 changes: 2 additions & 3 deletions app/src/main/java/com/bnyro/clock/util/AlarmHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import java.util.GregorianCalendar

object AlarmHelper {
const val EXTRA_ID = "alarm_id"
private const val HOUR_IN_MILLIS = 60 * 60 * 1000

@SuppressLint("ScheduleExactAlarm")
fun enqueue(context: Context, alarm: Alarm) {
Expand Down Expand Up @@ -91,9 +90,9 @@ object AlarmHelper {

if (calendar.timeZone.useDaylightTime()) {
if (calendar.timeZone.inDaylightTime(now) && !calendar.timeZone.inDaylightTime(calendar.time)) {
calendar.timeInMillis += HOUR_IN_MILLIS
calendar.timeInMillis += calendar.timeZone.dstSavings
} else if (!calendar.timeZone.inDaylightTime(now) && calendar.timeZone.inDaylightTime(calendar.time)) {
calendar.timeInMillis -= HOUR_IN_MILLIS
calendar.timeInMillis -= calendar.timeZone.dstSavings
}
}
}
Expand Down

0 comments on commit b8b5b90

Please sign in to comment.