feature/ScheduleCommand #5

Merged
moonleay merged 7 commits from feature/ScheduleCommand into master 2024-01-19 21:47:20 +00:00
Showing only changes of commit 05b4dc39b5 - Show all commits

View file

@ -1,6 +1,6 @@
/*
* lilJudd
* Copyright (C) 2023 moonleay
* Copyright (C) 2024 moonleay
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -177,6 +177,24 @@ object TimeUtil {
return ZonedDateTime.of(localDateTime, zoneId).toEpochSecond() * 1000
}
fun getTimeFromJSONTime(inp: String, zone: String): String {
// 2023-10-05T08:00:00Z
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
val localDateTime = LocalDateTime.parse(inp, formatter)
val zoneId = ZoneId.of(zone) // TODO: Add the possibility to set your timezone
val returnFormat = DateTimeFormatter.ofPattern("HH:mm")
return ZonedDateTime.of(localDateTime, zoneId).format(returnFormat)
}
fun getTimeFromJSONTimeLong(inp: String, zone: String): String {
// 2023-10-05T08:00:00Z
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
val localDateTime = LocalDateTime.parse(inp, formatter)
val zoneId = ZoneId.of(zone) // TODO: Add the possibility to set your timezone
val returnFormat = DateTimeFormatter.ofPattern("dd'/'MM',' HH:mm")
return ZonedDateTime.of(localDateTime, zoneId).format(returnFormat)
}
fun getTimeDifferenceFormatted(start: Long, end: Long): String {
val diff = end - start
return getTimeFormatedShortend(diff, false)