recruit-mp / LightCalendarView

A lightweight monthly calendar view for Android, fully written in Kotlin. Designed to meet the minimum demands for typical calendars.
Apache License 2.0
445 stars 67 forks source link

setAccents does not work for different time zones #11

Closed andytung closed 7 years ago

andytung commented 7 years ago

I have three dates in PST time zone: Dec 27, Dec 01, Dec 13 When I call setAccents they get set on Dec 26, Nov 30, Dec 12

val map = mutableMapOf<Date, Collection<Accent>>().apply {
    calendarMap.forEach { entry ->
        val (date, list) = entry
        val keyDate = dateFormatter.parse(date)
        Log.v(TAG, keyDate.toString())
        put(keyDate, list.map { value ->
            DotAccent(10f, key = value.startDate)
        })
    }
}
monthView?.setAccents(map)
12-12 16:48:01.108 6864-6864/? V/MainActivity: Tue Dec 27 00:00:00 PST 2016
12-12 16:48:01.108 6864-6864/? V/MainActivity: Thu Dec 01 00:00:00 PST 2016
12-12 16:48:01.108 6864-6864/? V/MainActivity: Tue Dec 13 00:00:00 PST 2016

If I switch my phone time zone to Tokyo time, it will show on the right dates.

recruit-mahayash commented 7 years ago

Hi @andytung, Thanks for the report.

I am not sure why this issue occurs since the library uses the default timezone (TimeZone.getDefault()) and default locale (Locale.getDefault()). We will add a feature to change the timezone and locale to use in the library.

Thank you.

recruit-mahayash commented 7 years ago

You can now set TimeZone and Locale explicitly in Release 1.0.1.

Thanks!