All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
commonMain.krono.DateTimePresenter.kt Maven / Gradle / Ivy
@file:JsExport
@file:Suppress("NON_EXPORTABLE_TYPE")
package krono
import krono.internal.AbstractZonedDateTime
import krono.utils.DaysOfMonth
import kotlinx.JsExport
import kotlin.js.JsName
data class DateTimePresenter(
override val date: LocalDate,
override val time: LocalTime,
override val zone: TimeZone,
val pattern: PresenterPattern
) : AbstractZonedDateTime(date, time, zone) {
@JsName("_ignore_from")
constructor(
year: Int,
monthNumber: Int,
dayOfMonth: Int,
hour: Int,
minute: Int,
second: Int,
nanosecond: Int,
tz: TimeZone,
pattern: PresenterPattern
) : this(LocalDate(year, monthNumber, dayOfMonth).getOrThrow(), LocalTime(hour, minute, second, nanosecond).getOrThrow(), tz, pattern)
override fun atDate(date: Int) = DateTimePresenter(year, monthNumber, date, hour, minute, second, nanosecond, zone, pattern)
override fun atEndOfMonth() = DateTimePresenter(date.atDate(DaysOfMonth(year, monthNumber)), time, zone, pattern)
val formatter = pattern.formatter
fun toDateString(): String = formatter.date.formatDate(date.year, date.monthNumber, date.dayOfMonth)
fun toTimeString(): String = formatter.time.formatTime(time.hour, time.minute, time.second)
fun toDateTimeString(): String = formatter.dateTime.formatDateTime(date.year, date.monthNumber, date.dayOfMonth, time.hour, time.minute, time.second)
}