package com.isidroid.c23.data.source.local

import androidx.room.TypeConverter
import com.google.gson.GsonBuilder
import java.util.Date

object RoomConverters {
    private val gson = GsonBuilder()
        .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZZ")
        .setLenient()
        .create()

    @TypeConverter fun fromTimestamp(value: Long?): Date? = value?.let { Date(it) }
    @TypeConverter fun dateToTimestamp(date: Date?): Long? = date?.time

    @TypeConverter fun fromListString(value: List<String>?): String? = value?.joinToString(",")
    @TypeConverter fun stringToListString(value: String?): List<String>? = value?.let { v -> v.split(",").map { it.trim() } }
}