LibreTube/app/src/main/java/com/github/libretube/db/Converters.kt

22 lines
556 B
Kotlin
Raw Normal View History

2023-03-01 19:49:27 +05:30
package com.github.libretube.db
import androidx.room.TypeConverter
import java.nio.file.Path
import java.nio.file.Paths
2023-03-01 19:49:27 +05:30
import kotlinx.datetime.LocalDate
import kotlinx.datetime.toLocalDate
object Converters {
@TypeConverter
fun localDateToString(localDate: LocalDate?) = localDate?.toString()
@TypeConverter
fun stringToLocalDate(string: String?) = string?.toLocalDate()
@TypeConverter
fun pathToString(path: Path?) = path?.toString()
@TypeConverter
fun stringToPath(string: String?) = string?.let { Paths.get(it) }
2023-03-01 19:49:27 +05:30
}