package com.suno.android.ui.screens.home.notifications import com.suno.android.common_networking.remote.entities.NotificationsInner import java.time.Instant import java.time.LocalDate import java.time.ZoneId import java.time.temporal.ChronoUnit fun List.xGroupByTimeframe(): Map> { val now = Instant.now() val zoneId = ZoneId.systemDefault() val todayStart = LocalDate.now(zoneId).atStartOfDay(zoneId).toInstant() return groupBy { notification -> val createdAt = Instant.parse(notification.updatedAt) val createdDate = createdAt.atZone(zoneId).toInstant() when { createdDate.isAfter(todayStart) -> "Today" ChronoUnit.DAYS.between(createdDate, now) <= 1 -> "Yesterday" ChronoUnit.DAYS.between(createdDate, now) <= 7 -> "Past Week" ChronoUnit.DAYS.between(createdDate, now) <= 30 -> "Past Month" else -> "Older" } } }