package app.furmeet.events.system.helper

import java.text.SimpleDateFormat

private fun getSimpleDateFormat(pattern: String) = SimpleDateFormat(pattern, resources.runtimeLanguage.locale)

fun Long.formatAsHoursAndMinutes() = getSimpleDateFormat(mapOf(Language.EN to "hh:mm a")[resources.runtimeLanguage]
        ?: "HH:mm").format(this)

fun Long.formatAsDayOfWeek() = getSimpleDateFormat("E").format(this)
fun Long.formatAsDayOfMonth() = getSimpleDateFormat("d").format(this)
fun Long.formatAsMonthName() = getSimpleDateFormat("MMM").format(this)
fun Long.formatAsLongDayOfWeekWithNumber() = getSimpleDateFormat("EEEE (d)").format(this)
fun Long.formatAsDayOfWeekNumberNoParenthesis() = getSimpleDateFormat("E d").format(this)
fun Long.formatAsTextuallyPleasantDate() = getSimpleDateFormat(mapOf(Language.EN to "MMM d (E), h:mm a")[resources.runtimeLanguage]
        ?: "d MMM (E), H:mm").format(this)

fun Long.formatAsIso() = getSimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(this)