From 77abe7ee2c906747d80813fef8d786b3e8d94c0a Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sun, 18 Apr 2021 02:48:59 +0530 Subject: format-common: initial API for PasswordEntry Signed-off-by: Harsh Shandilya --- .../kotlin/dev/msfjarvis/aps/util/time/Clocks.kt | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 format-common/src/main/kotlin/dev/msfjarvis/aps/util/time/Clocks.kt (limited to 'format-common/src/main/kotlin/dev/msfjarvis/aps/util/time') diff --git a/format-common/src/main/kotlin/dev/msfjarvis/aps/util/time/Clocks.kt b/format-common/src/main/kotlin/dev/msfjarvis/aps/util/time/Clocks.kt new file mode 100644 index 00000000..087a5028 --- /dev/null +++ b/format-common/src/main/kotlin/dev/msfjarvis/aps/util/time/Clocks.kt @@ -0,0 +1,26 @@ +/* + * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. + * SPDX-License-Identifier: GPL-3.0-only + */ + +package dev.msfjarvis.aps.util.time + +import java.time.Clock +import java.time.Instant +import java.time.ZoneId +import javax.inject.Inject + +/** + * A subclass of [Clock] that uses [Clock.systemDefaultZone] to get a clock that works for the + * user's current time zone. + */ +public open class UserClock @Inject constructor() : Clock() { + + private val clock = systemDefaultZone() + + override fun withZone(zone: ZoneId): Clock = clock.withZone(zone) + + override fun getZone(): ZoneId = clock.zone + + override fun instant(): Instant = clock.instant() +} -- cgit v1.2.3