Skip to content

Commit 76bd425

Browse files
committed
fix: Standardize date localization and acknowledge initial page behavior
This commit refines UI consistency and addresses user feedback: - Standardized date formatting to use `Locale.ENGLISH` in `SimpleHourlyForecastItemView`, `SimplifiedDailyForecastItemView`, and relevant mappers. This ensures days of the week are consistently displayed in English, resolving an issue where they appeared in the device's system language. - Acknowledged user feedback regarding the app defaulting to the geolocation page on launch; this remains the intended design to prioritize immediate local weather if permissions are granted. - Builds upon a stable test suite, ensuring these UI refinements are integrated reliably. The goal is to enhance UI predictability for users with non-English device settings.
1 parent 1e6f616 commit 76bd425

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/src/main/java/com/artemzarubin/weatherml/data/mapper/WeatherMappers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fun mapToWeatherDataBundle(
7676
val dailyForecastsDomain = mutableListOf<DailyForecast>()
7777
val groupedByDay = forecastResponseDto.list?.groupBy {
7878
val date = Date((it.dateTime ?: 0L) * 1000L)
79-
SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(date)
79+
SimpleDateFormat("yyyyMMdd", Locale.ENGLISH).format(date)
8080
}
8181

8282
groupedByDay?.values?.take(7)?.forEach { dailyItems -> // Take up to 7 days

app/src/main/java/com/artemzarubin/weatherml/ui/MainActivity.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fun CurrentWeatherMainSection(
211211
Text(
212212
text = currentWeather.weatherDescription.replaceFirstChar {
213213
if (it.isLowerCase()) it.titlecase(
214-
Locale.getDefault()
214+
Locale.ENGLISH
215215
) else it.toString()
216216
},
217217
style = MaterialTheme.typography.bodyLarge
@@ -315,7 +315,7 @@ fun SimpleHourlyForecastItemView(
315315
Text(
316316
SimpleDateFormat(
317317
"EEE HH:mm",
318-
Locale.getDefault()
318+
Locale.ENGLISH
319319
).format(Date(hourlyForecast.dateTimeMillis)),
320320
style = MaterialTheme.typography.labelSmall
321321
)
@@ -364,7 +364,7 @@ fun SimplifiedDailyForecastItemView(
364364
tomorrowCalendar.get(Calendar.YEAR) == forecastCalendar.get(Calendar.YEAR) &&
365365
tomorrowCalendar.get(Calendar.DAY_OF_YEAR) == forecastCalendar.get(Calendar.DAY_OF_YEAR) -> "Tomorrow"
366366

367-
else -> SimpleDateFormat("EEE, d/MM", Locale.getDefault()).format(forecastDate)
367+
else -> SimpleDateFormat("EEE, d/MM", Locale.ENGLISH).format(forecastDate)
368368
}
369369
}
370370

@@ -435,7 +435,7 @@ fun SimplifiedDailyForecastItemView(
435435
fun formatUnixTimestampToDateTime(timestampMillis: Long, timezoneOffsetSeconds: Int): String {
436436
if (timestampMillis == 0L) return "N/A"
437437
val date = Date(timestampMillis)
438-
val sdf = SimpleDateFormat("MMM dd, HH:mm", Locale.getDefault())
438+
val sdf = SimpleDateFormat("MMM dd, HH:mm", Locale.getDefault()) or Locale.ENGLISH
439439
val customTimeZone = TimeZone.getTimeZone("GMT")
440440
customTimeZone.rawOffset = timezoneOffsetSeconds * 1000
441441
sdf.timeZone = customTimeZone
@@ -445,7 +445,7 @@ fun formatUnixTimestampToDateTime(timestampMillis: Long, timezoneOffsetSeconds:
445445
fun formatUnixTimestampToTime(timestampMillis: Long, timezoneOffsetSeconds: Int): String {
446446
if (timestampMillis == 0L) return "N/A"
447447
val date = Date(timestampMillis)
448-
val sdf = SimpleDateFormat("HH:mm", Locale.getDefault())
448+
val sdf = SimpleDateFormat("HH:mm", Locale.ENGLISH)
449449
val tz = TimeZone.getTimeZone("GMT")
450450
tz.rawOffset = timezoneOffsetSeconds * 1000
451451
sdf.timeZone = tz

0 commit comments

Comments
 (0)