use real-time instead of outdated saved timestamp closes #1088

This commit is contained in:
pranshulgg committed 2026-09-14 21:59:20 +05:30
1 parent 32ac4f4ca2
commit cb095feeec
45 files changed
+67 -67

No files matched your search

@@ -23,7 +23,6 @@ data class WeatherCurrent(
val uvIndex: Double?,
val weatherCondition: WeatherCondition,
val feelsLike: Double?,
val time: Long, // NOTE: ALWAYS MILLISECONDS
val dewPoint: Double?,
val utcOffsetSeconds: Long?,
val lastUpdatedInMilli: Long
@@ -10,6 +10,7 @@ import com.pranshulgg.weather_master_app.core.model.domain.weather.WeatherUnits
import com.pranshulgg.weather_master_app.core.model.weather.WeatherCondition
import com.pranshulgg.weather_master_app.core.model.weather.toLabel
import com.pranshulgg.weather_master_app.core.prefs.AppPrefsState
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.safeZoneId
import com.pranshulgg.weather_master_app.core.utils.locale.getCurrentAppLocale
import com.pranshulgg.weather_master_app.core.utils.weather.computing.computeDailyWeatherCondition
@@ -36,7 +37,7 @@ fun computeDaySummary(
val currentIndex = findHourlyIndexForTime(
hourly.map { it.time },
weather.current.time
getCurrentTimeFor(weather.location.timezone)
)
@@ -3,8 +3,10 @@ package com.pranshulgg.weather_master_app.data.local
import android.content.Context
import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.DeleteColumn
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.migration.AutoMigrationSpec
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import com.pranshulgg.weather_master_app.data.local.dao.airquality.AirQualityDao
@@ -31,6 +33,12 @@ import com.pranshulgg.weather_master_app.data.local.entity.weather.blocks.Weathe
import com.pranshulgg.weather_master_app.data.local.entity.weather.nws.NwsGridPointsEntity
import com.pranshulgg.weather_master_app.data.local.entity.weather.units.AppWeatherUnitsEntity
@DeleteColumn(
tableName = "weather_current",
columnName = "time"
)
class WeatherCurrentDeleteTimeSpec : AutoMigrationSpec
@Database(
entities = [
WeatherLocationEntity::class,
@@ -47,7 +55,7 @@ import com.pranshulgg.weather_master_app.data.local.entity.weather.units.AppWeat
AlertEntity::class,
ApiKeyEntity::class
],
version = 59,
version = 60,
autoMigrations = [
AutoMigration(from = 39, to = 40),
AutoMigration(from = 42, to = 43),
@@ -62,9 +70,11 @@ import com.pranshulgg.weather_master_app.data.local.entity.weather.units.AppWeat
AutoMigration(from = 54, to = 55),
AutoMigration(from = 56, to = 57),
AutoMigration(from = 57, to = 58),
AutoMigration(from = 58, to = 59)
]
AutoMigration(from = 58, to = 59),
AutoMigration(from = 59, to = 60, spec = WeatherCurrentDeleteTimeSpec::class)
],
)
abstract class WeatherMasterDatabase : RoomDatabase() {
abstract fun weatherContextDao(): WeatherContextDao
@@ -74,11 +84,8 @@ abstract class WeatherMasterDatabase : RoomDatabase() {
abstract fun airQualityDao(): AirQualityDao
abstract fun nwsDao(): NwsDao
abstract fun githubDao(): GithubDao
abstract fun locationKeysDao(): LocationKeysDao
abstract fun alertsDao(): AlertsDao
abstract fun apiKeysDao(): ApiKeysDao
companion object {
@@ -217,4 +224,5 @@ val MIGRATION_55_56 = object : Migration(55, 56) {
)
}
}
}
}
@@ -22,7 +22,6 @@ import com.pranshulgg.weather_master_app.data.local.entity.location.WeatherLocat
)
data class CurrentWeatherEntity(
val locationId: String,
val temperature: Double?,
val humidity: Double?,
val windSpeed: Double?,
@@ -33,10 +32,7 @@ data class CurrentWeatherEntity(
val uvIndex: Double?,
val weatherCondition: WeatherCondition,
val feelsLike: Double?,
val time: Long,
val dewPoint: Double?,
val utcOffsetSeconds: Long?,
val lastUpdatedInMilli: Long
)
@@ -25,7 +25,6 @@ fun WeatherCurrent.toCurrentWeatherEntity(
uvIndex = uvIndex,
weatherCondition = weatherCondition,
feelsLike = feelsLike,
time = time,
dewPoint = dewPoint,
utcOffsetSeconds = utcOffsetSeconds,
lastUpdatedInMilli = lastUpdatedInMilli
@@ -7,6 +7,7 @@ import com.pranshulgg.weather_master_app.core.model.domain.weather.WeatherCurren
import com.pranshulgg.weather_master_app.core.model.domain.weather.WeatherDaily
import com.pranshulgg.weather_master_app.core.model.domain.weather.WeatherHourly
import com.pranshulgg.weather_master_app.core.model.weather.WeatherCondition
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.safeZoneId
import com.pranshulgg.weather_master_app.core.utils.weather.cache.isWeatherDomainSafe
import com.pranshulgg.weather_master_app.data.local.entity.weather.DailyWeatherEntity
@@ -23,7 +24,7 @@ fun WeatherWithRelations.toDomain(): Weather? {
// DROP PAST DAYS
val todayIndex = getDailyIndexForToday(
current?.time ?: System.currentTimeMillis(),
getCurrentTimeFor(timezone),
daily,
timezone
).coerceAtLeast(0)
@@ -54,7 +55,6 @@ fun WeatherWithRelations.toDomain(): Weather? {
uvIndex = current?.uvIndex,
weatherCondition = current?.weatherCondition ?: WeatherCondition.NO_CONDITION_FOUND,
feelsLike = current?.feelsLike,
time = current?.time ?: -1L,
dewPoint = current?.dewPoint,
utcOffsetSeconds = current?.utcOffsetSeconds,
lastUpdatedInMilli = current?.lastUpdatedInMilli ?: -1L
@@ -58,7 +58,6 @@ fun AccuWeatherBundle.toDomain(location: Location): Weather {
uvIndex = current.uvIndex,
weatherCondition = AccuWeatherConditionMap.getCondition(current.weatherIcon),
feelsLike = current.feelsLike.metric.value,
time = current.time.secondsToMilliseconds(),
dewPoint = current.dewPoint.metric.value,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -76,7 +76,6 @@ fun AemetForecastJson.toDomain(location: Location): Weather {
uvIndex = null,
weatherCondition = current?.condition ?: WeatherCondition.NO_CONDITION_FOUND,
feelsLike = current?.feelsLike,
time = currentTime,
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -46,7 +46,6 @@ fun BmkgForecastBundle.toDomain(location: Location): Weather {
current.humidity,
WindSpeedUnit.KPH.convert(current.windSpeed, WindSpeedUnit.MPS)
),
time = current.datetime.iso8601TimestampToMilliseconds(),
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -64,7 +64,6 @@ fun ChinaForecastJson.toDomain(location: Location): Weather {
current.weather.toSafeDouble()?.toInt()
),
feelsLike = current.feelsLike.value.toSafeDouble(),
time = current.pubTime.iso8601TimestampToMilliseconds(),
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -89,7 +89,6 @@ fun CwaForecastBundle.toDomain(location: Location): Weather {
uvIndex = null,
weatherCondition = current?.condition ?: WeatherCondition.NO_CONDITION_FOUND,
feelsLike = current?.feelsLike,
time = currentTime,
dewPoint = current?.dewPoint,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -47,7 +47,6 @@ fun DwdWeatherJsonBundle.toDomain(location: Location): Weather {
current.humidity?.toDouble(),
current.windSpeed?.kmhToMs()
),
time = current.timestamp.iso8601TimestampToMilliseconds(),
dewPoint = current.dewPoint,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -85,7 +85,6 @@ fun EcccWeatherJson.toDomain(location: Location): Weather {
WindSpeedUnit.MPS
)
),
time = current.timeStamp.iso8601TimestampToMilliseconds(),
dewPoint = current.dewpoint.metric?.toSafeDouble(),
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -108,7 +108,6 @@ fun FmiWeather.toDomain(location: Location): Weather {
currentDataForParam("rh"),
currentDataForParam("ws_10min")
),
time = if (current != null) current["t2m"]?.get(0)!!.time!!.iso8601TimestampToMilliseconds() else forecast.keys.sorted()[currentHour],
dewPoint = currentDataForParam("td"),
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -71,7 +71,6 @@ fun GismeteoModel.toDomain(location: Location): Weather {
uvIndex = null,
weatherCondition = GismeteoWeatherConditionMap.getCondition(current.icon),
feelsLike = current.feelsLike,
time = fixTimeString(current.time).iso8601TimestampToMilliseconds(),
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis(),
@@ -159,7 +159,6 @@ fun ImdForecastModel.toDomain(location: Location): Weather {
WindSpeedUnit.MPS
),
),
time = currentTime,
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -340,7 +340,6 @@ private fun createCurrentFromObservation(
uvIndex = null,
weatherCondition = WeatherCondition.NO_CONDITION_FOUND,
feelsLike = computeApparentTemperature(temp, humidity, windMs),
time = timeMilli,
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -399,7 +398,6 @@ private fun createCurrentFromForecast(
uvIndex = null,
weatherCondition = condition,
feelsLike = computeApparentTemperature(temp, humidity, windMs),
time = System.currentTimeMillis(),
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -79,7 +79,6 @@ fun List<IpmaForecastJson>.toDomain(location: Location): Weather {
current.humidity.toSafeDouble(),
WindSpeedUnit.KPH.convert(current.windSpeed.toSafeDouble(), WindSpeedUnit.MPS)
),
time = nowMillis,
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -144,7 +144,6 @@ fun JmaForecastBundle.toDomain(location: Location): Weather {
uvIndex = null,
weatherCondition = nearestHourPoint?.condition ?: WeatherCondition.NO_CONDITION_FOUND,
feelsLike = amedasFeelsLike,
time = currentTime,
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -88,7 +88,6 @@ fun MeteoamWeatherBundle.toDomain(location: Location): Weather {
current.temperature.value, current.humidity.value,
WindSpeedUnit.KPH.convert(current.windSpeedKmh.value, WindSpeedUnit.MPS)
),
time = time.iso8601TimestampToMilliseconds(),
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -52,7 +52,6 @@ fun MeteoFranceForecastJson.toDomain(location: Location): Weather {
forecast[currentHour].temperature, forecast[currentHour].humidity?.toDouble(),
forecast[currentHour].windSpeed?.toDouble()
),
time = forecast[currentHour].time.secondsToMilliseconds(),
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -61,7 +61,6 @@ fun MetNorwayForecastJson.toDomain(location: Location): Weather {
current.instant.details.relativeHumidity,
current.instant.details.windSpeed
),
time = currentTime,
dewPoint = current.instant.details.dewPoint,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -70,7 +70,6 @@ fun MetOfficeForecastJson.toDomain(location: Location): Weather {
uvIndex = hourly[currentHourIndex].uvIndex,
weatherCondition = MetOfficeWeatherConditionMap.getCondition(hourly[currentHourIndex].significantWeatherCode),
feelsLike = hourly[currentHourIndex].feelsLikeTemperature,
time = currentTime,
dewPoint = hourly[currentHourIndex].screenDewPointTemperature,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -129,7 +129,6 @@ fun NwsWeatherJsonBundle.toDomain(location: Location): Weather {
current.relativeHumidity.value,
current.windSpeed.value?.kmhToMs()
),
time = current.timestamp.iso8601TimestampToMilliseconds(),
dewPoint = hourly.periods[currentHourIndex].dewPoint.value,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -62,7 +62,6 @@ fun OpenMeteoWeatherJson.toDomain(location: Location): Weather {
uvIndex = current.uvIndex,
weatherCondition = OpenMeteoWeatherConditionMap.getCondition(current.weatherCode),
feelsLike = current.feelsLike,
time = current.time.secondsToMilliseconds(), // Open-Meteo returns in seconds
dewPoint = hourly.dewPoint[currentHourIndex],
utcOffsetSeconds = utcOffsetSeconds,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -64,7 +64,6 @@ fun OpenWeatherJsonBundle.toDomain(location: Location): Weather {
uvIndex = null,
weatherCondition = OpenWeatherConditionMap.getCondition(current.weather[0].icon),
feelsLike = current.main.feelsLike,
time = current.dt.secondsToMilliseconds(),
dewPoint = current.main.dewPoint,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -66,7 +66,6 @@ private fun PirateWeatherCurrentJson.toWeatherCurrent(
uvIndex = uvIndex,
weatherCondition = PirateWeatherConditionMap.getCondition(icon),
feelsLike = apparentTemperature,
time = time.secondsToMilliseconds(),
dewPoint = dewPoint,
utcOffsetSeconds = utcOffsetSeconds,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -53,7 +53,6 @@ fun SmhiForecastJson.toDomain(location: Location): Weather {
current.humidity?.toDouble(),
current.windSpeed
),
time = currentTime,
dewPoint = null,
utcOffsetSeconds = null,
lastUpdatedInMilli = System.currentTimeMillis()
@@ -7,6 +7,7 @@ import com.pranshulgg.weather_master_app.core.model.domain.weather.Weather
import com.pranshulgg.weather_master_app.core.model.weather.WeatherCondition
import com.pranshulgg.weather_master_app.core.model.weather.toLabel
import com.pranshulgg.weather_master_app.core.model.weather.wind.WindDirection
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import org.json.JSONArray
import org.json.JSONObject
import kotlin.math.roundToInt
@@ -15,7 +16,7 @@ import kotlin.math.roundToInt
fun sendGadgetBridgeWeatherData(context: Context, weather: Weather) {
try {
val rootWeatherJson = JSONObject().apply {
put("timestamp", weather.current.time / 1000L)
put("timestamp", getCurrentTimeFor(weather.location.timezone) / 1000L)
put("location", weather.location.name)
put("currentTemp", weather.current.temperature?.inKelvin())
put("todayMinTemp", weather.daily[0].temperatureMin?.inKelvin())
@@ -35,12 +35,12 @@ fun widgetWeatherMapper(
val currentCondition = weather.current.weatherCondition.toLabel(applicationContext)
val currentIcon = weather.current.weatherCondition.toIcon(
targetTimeMilli = weather.current.time,
targetTimeMilli = getCurrentTimeFor(timezone),
daily = weather.daily.firstOrNull()
)
val currentFrogIcon = weather.current.weatherCondition.toFroggy(
targetTimeMilli = weather.current.time,
targetTimeMilli = getCurrentTimeFor(timezone),
daily = weather.daily.firstOrNull()
)
@@ -33,6 +33,7 @@ import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.LargeTopBarScaffold
import com.pranshulgg.weather_master_app.core.ui.components.NavigateUpBtn
import com.pranshulgg.weather_master_app.core.utils.extensions.DateTimeExtensions.secondsToMilliseconds
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.toDateString
import com.pranshulgg.weather_master_app.core.utils.weather.airquality.AirQualityColors
import com.pranshulgg.weather_master_app.feature.blocks.BlocksScreenViewModel
@@ -46,13 +47,12 @@ fun AirQualityScreen(navController: NavController, index: Int = 0, locationId: S
val viewModel: BlocksScreenViewModel = hiltViewModel()
val airQuality = viewModel.weather.collectAsState().value.airQuality ?: return
val weather = viewModel.weather.collectAsState().value.weather ?: return
val hourly = airQuality.hourly
val time = if (index != 0) weather.daily[index].time else weather.current.time
val time =
if (index != 0) weather.daily[index].time else getCurrentTimeFor(weather.location.timezone)
val context = LocalContext.current
val date = toDateString(weather.daily[index].time, weather.location.timezone)
@@ -36,6 +36,7 @@ import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.LargeTopBarScaffold
import com.pranshulgg.weather_master_app.core.ui.components.NavigateUpBtn
import com.pranshulgg.weather_master_app.core.ui.components.Symbol
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.toDateString
import com.pranshulgg.weather_master_app.core.utils.weather.forecast.findMatchingHourly
import com.pranshulgg.weather_master_app.feature.blocks.BlocksScreenViewModel
@@ -55,7 +56,8 @@ fun HumidityScreen(navController: NavController, index: Int = 0, locationId: Str
val weather = viewModel.weather.collectAsState().value.weather
val hourly = weather?.hourly ?: return
val units = viewModel.units.collectAsState().value.units
val time = if (index != 0) weather.daily[index].time else weather.current.time
val time =
if (index != 0) weather.daily[index].time else getCurrentTimeFor(weather.location.timezone)
val context = LocalContext.current
val data = findMatchingHourly(
hourly,
@@ -23,6 +23,7 @@ import com.pranshulgg.weather_master_app.R
import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.LargeTopBarScaffold
import com.pranshulgg.weather_master_app.core.ui.components.NavigateUpBtn
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.toDateString
import com.pranshulgg.weather_master_app.core.utils.weather.forecast.findMatchingHourly
import com.pranshulgg.weather_master_app.feature.blocks.BlocksScreenViewModel
@@ -40,7 +41,8 @@ fun RainScreen(navController: NavController, index: Int = 0, locationId: String)
val context = LocalContext.current
val units = viewModel.units.collectAsState().value.units
val zoneId = weather.location.timezone
val time = if (index != 0) weather.daily[index].time else weather.current.time
val time =
if (index != 0) weather.daily[index].time else getCurrentTimeFor(weather.location.timezone)
val data = findMatchingHourly(
@@ -23,6 +23,7 @@ import com.pranshulgg.weather_master_app.R
import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.LargeTopBarScaffold
import com.pranshulgg.weather_master_app.core.ui.components.NavigateUpBtn
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.toDateString
import com.pranshulgg.weather_master_app.core.utils.weather.forecast.findMatchingHourly
import com.pranshulgg.weather_master_app.feature.blocks.BlocksScreenViewModel
@@ -42,7 +43,8 @@ fun SnowScreen(navController: NavController, index: Int = 0, locationId: String)
val context = LocalContext.current
val units = viewModel.units.collectAsState().value.units
val zoneId = weather.location.timezone
val time = if (index != 0) weather.daily[index].time else weather.current.time
val time =
if (index != 0) weather.daily[index].time else getCurrentTimeFor(weather.location.timezone)
val data = findMatchingHourly(
@@ -23,6 +23,7 @@ import com.pranshulgg.weather_master_app.R
import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.LargeTopBarScaffold
import com.pranshulgg.weather_master_app.core.ui.components.NavigateUpBtn
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.toDateString
import com.pranshulgg.weather_master_app.core.utils.weather.forecast.findMatchingHourly
import com.pranshulgg.weather_master_app.feature.blocks.BlocksScreenViewModel
@@ -41,7 +42,8 @@ fun PressureScreen(navController: NavController, index: Int = 0, locationId: Str
val hourly = weather?.hourly ?: return
val units = viewModel.units.collectAsState().value.units
val zoneId = weather.location.timezone
val time = if (index != 0) weather.daily[index].time else weather.current.time
val time =
if (index != 0) weather.daily[index].time else getCurrentTimeFor(weather.location.timezone)
val context = LocalContext.current
@@ -34,6 +34,7 @@ import com.pranshulgg.weather_master_app.core.ui.components.AvatarIcon
import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.LargeTopBarScaffold
import com.pranshulgg.weather_master_app.core.ui.components.NavigateUpBtn
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.to12HourTimeString
import com.pranshulgg.weather_master_app.core.utils.formatters.to24HourTimeString
import com.pranshulgg.weather_master_app.core.utils.formatters.toDateString
@@ -57,7 +58,8 @@ fun UvIndexScreen(navController: NavController, index: Int = 0, locationId: Stri
val hourly = weather?.hourly ?: return
val context = LocalContext.current
val time = if (index != 0) weather.daily[index].time else weather.current.time
val time =
if (index != 0) weather.daily[index].time else getCurrentTimeFor(weather.location.timezone)
val data =
findMatchingHourly(
@@ -30,6 +30,7 @@ import com.pranshulgg.weather_master_app.core.prefs.LocalAppPrefs
import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.LargeTopBarScaffold
import com.pranshulgg.weather_master_app.core.ui.components.NavigateUpBtn
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.to12HourTimeString
import com.pranshulgg.weather_master_app.core.utils.formatters.to24HourTimeString
import com.pranshulgg.weather_master_app.core.utils.formatters.toDateString
@@ -68,7 +69,8 @@ fun VisibilityScreen(navController: NavController, index: Int = 0, locationId: S
val units = viewModel.units.collectAsState().value.units
val context = LocalContext.current
val time = if (index != 0) weather.daily[index].time else weather.current.time
val time =
if (index != 0) weather.daily[index].time else getCurrentTimeFor(weather.location.timezone)
val data = findMatchingHourly(
hourly,
@@ -23,6 +23,7 @@ import com.pranshulgg.weather_master_app.R
import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.LargeTopBarScaffold
import com.pranshulgg.weather_master_app.core.ui.components.NavigateUpBtn
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.toDateString
import com.pranshulgg.weather_master_app.core.utils.weather.forecast.findMatchingHourly
import com.pranshulgg.weather_master_app.feature.blocks.BlocksScreenViewModel
@@ -41,7 +42,8 @@ fun WindScreen(navController: NavController, index: Int = 0, locationId: String)
val units = viewModel.units.collectAsState().value.units
val context = LocalContext.current
val zoneId = weather.location.timezone
val time = if (index != 0) weather.daily[index].time else weather.current.time
val time =
if (index != 0) weather.daily[index].time else getCurrentTimeFor(weather.location.timezone)
val data = findMatchingHourly(
hourly,
@@ -36,6 +36,7 @@ import com.pranshulgg.weather_master_app.core.model.weather.toIcon
import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.SettingsTileIcon
import com.pranshulgg.weather_master_app.core.ui.theme.ShapeRadius
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.getLastUpdatedTimeString
import com.pranshulgg.weather_master_app.feature.shared.components.LocationItem
@@ -127,7 +128,7 @@ fun LocationsScreenContent(
onLocationSelect(location)
},
icon = icon.toIcon(
targetTimeMilli = weather?.current?.time ?: System.currentTimeMillis(),
targetTimeMilli = if (weather != null) getCurrentTimeFor(weather.location.timezone) else System.currentTimeMillis(),
daily = weather?.daily?.firstOrNull()
),
isSelected = location.id == activeLocation?.id,
@@ -9,6 +9,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.pranshulgg.weather_master_app.core.model.domain.weather.Weather
import com.pranshulgg.weather_master_app.core.model.weather.toFroggy
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
@Composable
fun FroggyContainer(weather: Weather) {
@@ -16,7 +17,7 @@ fun FroggyContainer(weather: Weather) {
Image(
painter = painterResource(
weather.current.weatherCondition.toFroggy(
targetTimeMilli = weather.current.time,
targetTimeMilli = getCurrentTimeFor(weather.location.timezone),
daily = weather.daily.firstOrNull()
)
),
@@ -15,6 +15,7 @@ import androidx.compose.ui.graphics.Color
import com.pranshulgg.weather_master_app.core.model.weather.WeatherCondition
import com.pranshulgg.weather_master_app.core.model.domain.weather.Weather
import com.pranshulgg.weather_master_app.core.ui.theme.isThemeDark
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.weather.cache.isWeatherDomainSafe
data class Background(
@@ -61,7 +62,7 @@ private fun backgroundGradients(weather: Weather?, isDark: Boolean = true): Back
val isDay = if (day != null && day.sunrise != null && day.sunset != null) {
weather.current.time in day.sunrise..day.sunset
getCurrentTimeFor(weather.location.timezone) in day.sunrise..day.sunset
} else {
true
}
@@ -25,6 +25,7 @@ import com.pranshulgg.weather_master_app.core.model.weather.toLabel
import com.pranshulgg.weather_master_app.core.ui.components.Gap
import com.pranshulgg.weather_master_app.core.ui.components.Symbol
import com.pranshulgg.weather_master_app.core.ui.components.WeatherIconBox
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
import com.pranshulgg.weather_master_app.core.utils.formatters.getLastUpdatedTimeString
import kotlin.math.roundToInt
@@ -84,7 +85,7 @@ private fun CardRowContent(weather: Weather, units: WeatherUnits, context: Conte
)
WeatherIconBox(
current.weatherCondition.toIcon(
targetTimeMilli = weather.current.time,
targetTimeMilli = getCurrentTimeFor(weather.location.timezone),
daily = weather.daily.firstOrNull()
),
size = 42.dp
@@ -188,7 +189,7 @@ fun PixelStyleCurrentWeatherCard(weather: Weather, units: WeatherUnits, context:
) {
WeatherIconBox(
current.weatherCondition.toIcon(
targetTimeMilli = weather.current.time,
targetTimeMilli = getCurrentTimeFor(weather.location.timezone),
daily = weather.daily.firstOrNull()
),
size = 32.dp
@@ -3,6 +3,7 @@ package com.pranshulgg.weather_master_app.feature.main.ui.weatherAnimations
import androidx.compose.runtime.Composable
import com.pranshulgg.weather_master_app.core.model.weather.WeatherCondition
import com.pranshulgg.weather_master_app.core.model.domain.weather.Weather
import com.pranshulgg.weather_master_app.core.utils.formatters.getCurrentTimeFor
@Composable
fun WeatherAnimations(weather: Weather, isFroggyLayout: Boolean) {
@@ -10,7 +11,7 @@ fun WeatherAnimations(weather: Weather, isFroggyLayout: Boolean) {
val day = weather.daily.firstOrNull()
val isDay = if (day != null && day.sunrise != null && day.sunset != null) {
weather.current.time in day.sunrise..day.sunset
getCurrentTimeFor(weather.location.timezone) in day.sunrise..day.sunset
} else {
true
}
@@ -31,7 +31,7 @@ fun notificationWeatherMapper(
val currentCondition = weather.current.weatherCondition.toLabel(applicationContext)
val currentIcon = weather.current.weatherCondition.toIcon(
targetTimeMilli = weather.current.time,
targetTimeMilli = getCurrentTimeFor(timezone),
daily = weather.daily.firstOrNull()
)
+8 -8
View File
@@ -10,18 +10,18 @@ espressoCore = "3.7.0"
kotlinxSerializationJson = "1.11.0"
lifecycleRuntimeKtx = "2.11.0"
activityCompose = "1.13.0"
kotlin = "2.4.10"
composeBom = "2026.08.00"
kotlin = "2.4.20"
composeBom = "2026.09.00"
material3 = "1.5.0-alpha26"
navigationCompose = "2.9.8"
materialKolor = "5.0.0"
foundationLayout = "1.12.0"
navigationCompose = "2.10.1"
materialKolor = "5.0.1"
foundationLayout = "1.12.1"
coil = "2.7.0"
coroutines = "1.11.0"
room = "2.8.4"
room = "2.8.5"
retrofit = "3.0.0"
okhttp = "5.4.0"
animationCore = "1.12.0"
okhttp = "5.5.0"
animationCore = "1.12.1"
core-splashscreen = "1.2.0"
hiltAndroid = "2.60.1"
hiltNavigationCompose = "1.4.0"