aminography / PrimeDatePicker

PrimeDatePicker is a tool that provides picking a single day, multiple days, and a range of days.
Apache License 2.0
471 stars 52 forks source link

No localization for date formats #74

Open akaish opened 1 year ago

akaish commented 1 year ago

Hello, I'm working on app that targeted to Russian\Ukrainian\Belarus audience and noticed that "Selected Day" section for single date dialog picker has US like formatting (yyyy/MM/dd) instead of dd/MM/yyyy (i mean that there is no support for locale dates formatting, in different countries order of year, month and day differs). Here is possible fix: File: com.aminography.primedatepicker.picker.selection.single.SingleDaySelectionBarView Fix (line 48):

    var pickedDay: PrimeCalendar? = null
        set(value) {
            field = value
            rootView.pickedTextView.bottomLabelText = value?.let {
                val dateFormatter: DateTimeFormatter =
                    DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG) // I prefer full date format

                val localDate = Instant.ofEpochMilli(it.timeInMillis)
                    .atZone(ZoneId.systemDefault())
                    .toLocalDate()
                localDate.format(dateFormatter).localizeDigits(value.locale)
            } ?: "---"
        }

By the way, good work. You've created really sweet looking widget easy both to use and implement in code.