package cz.muni.sutralog.lib

import java.time.LocalDate
import java.time.format.DateTimeFormatter

class SutralogStaticLib {
    companion object {
        private val dateFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy")

        fun dateToString(date: LocalDate?): String? {
            return date?.format(dateFormatter)
        }

        fun stringToDate(date: String?): LocalDate? {
            return if (date == null) null
            else {
                val split = date.split('.')
                LocalDate.of(split[2].toInt(), split[1].toInt(), split[0].toInt())
            }
        }

        fun getGoogleMapsLink(latitude: Double, longitude: Double, zoom: Int = 10): String {
            return "<a href=\"https://maps.google.com/?q=${latitude},${longitude}&ll=${latitude},${longitude}&z=$zoom\">Google Maps Link</a>"
        }
    }
}