CheckmarkDialog: Format date using current locale

This commit is contained in:
2022-01-01 06:30:57 -06:00
parent feeb4f057d
commit d875af8a8e
6 changed files with 31 additions and 15 deletions

View File

@@ -19,6 +19,7 @@
package org.isoron.platform.time
import java.text.DateFormat
import java.util.Calendar.DAY_OF_MONTH
import java.util.Calendar.DAY_OF_WEEK
import java.util.Calendar.HOUR_OF_DAY
@@ -66,4 +67,10 @@ class JavaLocalDateFormatter(private val locale: Locale) : LocalDateFormatter {
val cal = date.toGregorianCalendar()
return cal.getDisplayName(DAY_OF_WEEK, SHORT, locale)
}
fun longFormat(date: LocalDate): String {
val df = DateFormat.getDateInstance(DateFormat.LONG, locale)
df.timeZone = TimeZone.getTimeZone("UTC")
return df.format(date.toGregorianCalendar().time)
}
}

View File

@@ -18,6 +18,7 @@
*/
package org.isoron.uhabits.core.ui.screens.habits.list
import org.isoron.platform.time.LocalDate
import org.isoron.uhabits.core.commands.CommandRunner
import org.isoron.uhabits.core.commands.CreateRepetitionCommand
import org.isoron.uhabits.core.models.Habit
@@ -65,6 +66,7 @@ open class ListHabitsBehavior @Inject constructor(
screen.showCheckmarkDialog(
entry.value,
entry.notes,
timestamp.toLocalDate(),
timestamp.toDialogDateString(),
habit.color,
) { newValue, newNotes ->
@@ -168,8 +170,9 @@ open class ListHabitsBehavior @Inject constructor(
callback: NumberPickerCallback
)
fun showCheckmarkDialog(
value: Int,
selectedValue: Int,
notes: String,
date: LocalDate,
dateString: String,
color: PaletteColor,
callback: CheckMarkDialogCallback

View File

@@ -93,7 +93,7 @@ class HistoryCardPresenter(
screen.showCheckmarkDialog(
entry.value,
entry.notes,
timestamp.toDialogDateString(),
timestamp.toLocalDate(),
preferences,
habit.color,
) { newValue, newNotes ->
@@ -206,9 +206,9 @@ class HistoryCardPresenter(
callback: ListHabitsBehavior.NumberPickerCallback,
)
fun showCheckmarkDialog(
value: Int,
selectedValue: Int,
notes: String,
dateString: String,
date: LocalDate,
preferences: Preferences,
color: PaletteColor,
callback: ListHabitsBehavior.CheckMarkDialogCallback,