Skip to content

Commit bb66999

Browse files
committed
Cleanup
1 parent db46739 commit bb66999

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

core/windows/src/internal/TzdbInRegistry.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,7 @@ private class PerYearZoneRulesDataWithTransitions(
332332
val standardTransition get() =
333333
RecurringZoneRules.Rule(standardTransitionTime, offsetBefore = daylightOffset, offsetAfter = standardOffset)
334334

335-
override fun offsetAtYearStart(): UtcOffset =
336-
if (daylightTransitionTime.toLocalDateTime(2030) < standardTransitionTime.toLocalDateTime(2030))
337-
standardOffset else daylightOffset
335+
override fun offsetAtYearStart(): UtcOffset = standardOffset // TODO: not true in all years + all zones
338336

339337
override fun toString(): String = "standard offset is $standardOffset" +
340338
", daylight offset is $daylightOffset" +

core/windows/test/TimeZoneRulesCompleteTest.kt

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package kotlinx.datetime.test
88

99
import kotlinx.cinterop.*
10+
import kotlinx.cinterop.ptr
1011
import kotlinx.datetime.*
1112
import kotlinx.datetime.internal.*
1213
import platform.windows.*
@@ -57,15 +58,17 @@ class TimeZoneRulesCompleteTest {
5758
}
5859
}
5960
val rawData = memScoped {
60-
alloc<HKEYVar>().withRegistryKey(HKEY_LOCAL_MACHINE!!, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\$windowsName", { err ->
61-
return@memScoped null
62-
}) { hKey ->
61+
val hKey = alloc<HKEYVar>()
62+
RegOpenKeyExW(HKEY_LOCAL_MACHINE!!, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\$windowsName", 0u, KEY_READ.toUInt(), hKey.ptr)
63+
try {
6364
val cbDataBuffer = alloc<DWORDVar>()
6465
val SIZE_BYTES = 44
6566
val zoneInfoBuffer = allocArray<BYTEVar>(SIZE_BYTES)
6667
cbDataBuffer.value = SIZE_BYTES.convert()
67-
RegQueryValueExW(hKey, "TZI", null, null, zoneInfoBuffer, cbDataBuffer.ptr)
68+
RegQueryValueExW(hKey.value, "TZI", null, null, zoneInfoBuffer, cbDataBuffer.ptr)
6869
zoneInfoBuffer.readBytes(SIZE_BYTES).toHexString()
70+
} finally {
71+
RegCloseKey(hKey.value)
6972
}
7073
}
7174
throw AssertionError(

0 commit comments

Comments
 (0)