fix: Account for local timezone when fetching month events
This commit is contained in:
parent
b3d9e426a2
commit
c6c64bfa3f
|
@ -21,6 +21,7 @@ import com.p_vacho.neat_calendar.models.CalendarDay
|
|||
import kotlinx.coroutines.launch
|
||||
import java.time.ZoneOffset
|
||||
import java.time.YearMonth
|
||||
import java.time.ZoneId
|
||||
import java.time.format.TextStyle
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -72,8 +73,12 @@ class CalendarActivity : AppCompatActivity() {
|
|||
* Note that this also includes the events this user was invited into.
|
||||
*/
|
||||
private suspend fun fetchEventsForMonth(yearMonth: YearMonth): Map<Int, List<EventResponse>> {
|
||||
val startFrom = yearMonth.atDay(1).atStartOfDay().atOffset(ZoneOffset.UTC)
|
||||
val endTo = yearMonth.atEndOfMonth().atTime(23, 59, 59).atOffset(ZoneOffset.UTC)
|
||||
// Use the system's default time zone
|
||||
val zoneId = ZoneId.systemDefault()
|
||||
|
||||
// Get the start and end of the month in the local time zone
|
||||
val startFrom = yearMonth.atDay(1).atStartOfDay(zoneId).toOffsetDateTime()
|
||||
val endTo = yearMonth.atEndOfMonth().atTime(23, 59, 59).atZone(zoneId).toOffsetDateTime()
|
||||
|
||||
val userId = tokenManager.userId
|
||||
|
||||
|
|
Loading…
Reference in a new issue