All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.krono.internal.formatters.PureDateTimeFormatterImpl.kt Maven / Gradle / Ivy

package krono.internal.formatters

import krono.PureDateFormatter
import krono.PureDateTimeFormatter
import krono.PureTimeFormatter
import kotlinx.JsExport

@PublishedApi
internal class PureDateTimeFormatterImpl private constructor(
    private val pattern: String,
    private val dateFormatter: (String) -> PureDateFormatter,
    private val timeFormatter: (String) -> PureTimeFormatter
) : PureDateTimeFormatter, PureDateFormatter by dateFormatter(pattern), PureTimeFormatter by timeFormatter(pattern) {
    constructor(pattern: String) : this(pattern, { PureDateFormatterImpl(it) }, { PureTimeFormatterImpl(it) })

    override fun formatDateTime(year: Int, month: Int, day: Int, hour: Int, minutes: Int, seconds: Int): String {
        val timePattern = dateFormatter(pattern).formatDate(year, month, day)
        return timeFormatter(timePattern).formatTime(hour, minutes, seconds)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy