Only show date label in forecast data field if it changes
This commit is contained in:
parent
0f0bb9b35b
commit
48fcf1b693
@ -61,8 +61,8 @@ import kotlinx.coroutines.launch
|
|||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.time.temporal.ChronoUnit
|
|
||||||
import java.time.format.FormatStyle
|
import java.time.format.FormatStyle
|
||||||
|
import java.time.temporal.ChronoUnit
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class CycleHoursAction : ActionCallback {
|
class CycleHoursAction : ActionCallback {
|
||||||
@ -185,8 +185,8 @@ class WeatherForecastDataType(
|
|||||||
val hourOffset = widgetSettings?.currentForecastHourOffset ?: 0
|
val hourOffset = widgetSettings?.currentForecastHourOffset ?: 0
|
||||||
|
|
||||||
var previousDate: String? = let {
|
var previousDate: String? = let {
|
||||||
val unixTime = data.forecastData?.time?.firstOrNull()
|
val unixTime = data.forecastData?.time?.getOrNull(hourOffset)
|
||||||
val formattedDate = unixTime?.let { Instant.ofEpochSecond(it).atZone(ZoneId.systemDefault()).toLocalDate().toString() }
|
val formattedDate = unixTime?.let { Instant.ofEpochSecond(unixTime).atZone(ZoneId.systemDefault()).toLocalDate().format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)) }
|
||||||
|
|
||||||
formattedDate
|
formattedDate
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user