From d49e3ede4df28c5e10c351645423d864b26c961d Mon Sep 17 00:00:00 2001 From: Adolar0042 <39769465+Adolar0042@users.noreply.github.com> Date: Thu, 18 Jan 2024 21:32:33 +0100 Subject: [PATCH] feat(timeUtils): Long to Time String --- app/src/main/java/com/chouten/app/common/TimeUtils.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/com/chouten/app/common/TimeUtils.kt b/app/src/main/java/com/chouten/app/common/TimeUtils.kt index df78172..f0dc264 100644 --- a/app/src/main/java/com/chouten/app/common/TimeUtils.kt +++ b/app/src/main/java/com/chouten/app/common/TimeUtils.kt @@ -28,4 +28,15 @@ fun epochMillisToTime(epochMilli: Long, pattern: String = "HH:mm:ss"): String { timeZone = userTimeZone }.format(Date(epochMilli)) } +} + +/** + * Converts epoch milliseconds to a formatted time string. + * + * @param epochMilli The epoch time in milliseconds. + * @param pattern The desired pattern for formatting the time (default is "h:mm:ss"). + * @return The formatted time string of [epochMilli] in the pattern of [pattern]. + */ +fun Long.toTimeString(pattern: String = "HH:mm:ss"): String { + return epochMillisToTime(this, pattern) } \ No newline at end of file