aboutsummaryrefslogtreecommitdiffstats
path: root/format-common/src/main/kotlin/dev/msfjarvis/aps/util/time
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-04-18 02:48:59 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2021-04-18 04:03:17 +0530
commit77abe7ee2c906747d80813fef8d786b3e8d94c0a (patch)
tree8146a514df53fc6e51e5288e7cf7e46673247740 /format-common/src/main/kotlin/dev/msfjarvis/aps/util/time
parent931cc052a8f22b96e11d4bd8f9d069ef8ff92e21 (diff)
downloadHardenedPass-77abe7ee2c906747d80813fef8d786b3e8d94c0a.tar.gz
HardenedPass-77abe7ee2c906747d80813fef8d786b3e8d94c0a.zip
format-common: initial API for PasswordEntry
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'format-common/src/main/kotlin/dev/msfjarvis/aps/util/time')
-rw-r--r--format-common/src/main/kotlin/dev/msfjarvis/aps/util/time/Clocks.kt26
1 files changed, 26 insertions, 0 deletions
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()
+}