diff --git a/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/TemerityApi.kt b/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/TemerityApi.kt index 3f6333dc4ae4629e926961ad0f6611358ce1a9b7..cf4110f1d1ccd178aaa4965b05b9222c872ee3b1 100644 --- a/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/TemerityApi.kt +++ b/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/TemerityApi.kt @@ -34,6 +34,7 @@ import io.ktor.client.statement.HttpResponse import kotlinx.datetime.DateTimeUnit import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime +import kotlinx.datetime.TimeZone import kotlinx.datetime.format.DateTimeFormat import kotlinx.datetime.format.char import kotlinx.datetime.plus @@ -47,6 +48,32 @@ import kotlinx.datetime.plus public interface TemerityApi { + // Library version information functions + + /** + * Returns the version of the library. + * @return A [String] representing the version of the library. + */ + public val version: String + + /** + * Returns the build variant of the library. + * @return A [BuildVariant] enum object representing build variant of the library. + */ + public val buildVariant: BuildVariant + + /** + * Returns the date & time the library was built. + * @return A [LocalDateTime] representation of the date & time the library was built. + */ + public val buildDate: LocalDateTime + + /** + * Returns the timezone the library was built in. + * @return A [TimeZone] object representing the timezone the library was built in. + */ + public val buildTimeZone: TimeZone + // User API library functions /** diff --git a/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/core/Temerity.kt b/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/core/Temerity.kt index 9b0da2d15a6d2f6edbe8f741dd73923b982d1843..308ae29be437764f40e0f99a025f33276881520e 100644 --- a/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/core/Temerity.kt +++ b/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/core/Temerity.kt @@ -40,7 +40,6 @@ import edu.ucsc.its.temerity.di.LibModule.libModule import edu.ucsc.its.temerity.di.platformModule import edu.ucsc.its.temerity.extensions.coroutines.availableThreads import edu.ucsc.its.temerity.extensions.coroutines.createJobScope -import edu.ucsc.its.temerity.extensions.datetime.DateTimeExt import edu.ucsc.its.temerity.extensions.time.applyAuditLogFormat import edu.ucsc.its.temerity.extensions.time.applyScheduledSessionDateFormat import edu.ucsc.its.temerity.model.AuditLogEntry @@ -77,7 +76,6 @@ import kotlinx.coroutines.withContext import kotlinx.datetime.DateTimeUnit import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDateTime -import kotlinx.datetime.LocalTime import kotlinx.datetime.TimeZone import kotlinx.datetime.minus import kotlinx.serialization.SerializationException @@ -142,57 +140,37 @@ public class Temerity internal constructor( config = config, supportKtxNotebook = supportKtxNotebook, ) + } - /** - * Get the current date as a [LocalDate] object - * @return The current date as a [LocalDate] object - */ - @JvmStatic - @Suppress("MemberVisibilityCanBePrivate") - public fun currentDate(): LocalDate = DateTimeExt.currentDate() + /** + * The version of the Temerity library. + * This is updated with each release of the library and should not be modified. + * @return The version of the Temerity library as a semantic versioning-formatted [String] + */ + @Suppress("MemberVisibilityCanBePrivate") + public override val version: String = LIB_VERSION - /** - * Get the current time as a [LocalTime] object - * @return The current time as a [LocalTime] object - */ - @JvmStatic - @Suppress("MemberVisibilityCanBePrivate") - public fun currentTime(): LocalTime = DateTimeExt.currentTime() - - /** - * The version of the Temerity library. - * This is updated with each release of the library and should not be modified. - * @return The version of the Temerity library as a semantic versioning-formatted [String] - */ - @JvmStatic - @Suppress("MemberVisibilityCanBePrivate") - public val version: String = LIB_VERSION + /** + * The build variant of the library. + * Either [BuildVariant.DEBUG] or [BuildVariant.RELEASE]. + * @return The build variant of the library as a [BuildVariant] enum + */ + @Suppress("MemberVisibilityCanBePrivate") + public override val buildVariant: BuildVariant = BuildVariant.valueOf(BUILD_VARIANT) - /** - * The date & time when the Temerity library was built. - * @return The date & time when the Temerity library was built as a [LocalDateTime] object - */ - @JvmStatic - @Suppress("MemberVisibilityCanBePrivate") - public val buildDate: LocalDateTime = LocalDateTime.parse(BUILD_DATE) + /** + * The date & time when the Temerity library was built. + * @return The date & time when the Temerity library was built as a [LocalDateTime] object + */ + @Suppress("MemberVisibilityCanBePrivate") + public override val buildDate: LocalDateTime = LocalDateTime.parse(BUILD_DATE) - /** - * The timezone where the library was built. - * @return The timezone where the library was built as a [TimeZone] object - */ - @JvmStatic - @Suppress("MemberVisibilityCanBePrivate") - public val buildTimeZone: TimeZone = TimeZone.of(BUILD_TIMEZONE) - - /** - * The build variant of the library. - * Either [BuildVariant.DEBUG] or [BuildVariant.RELEASE]. - * @return The build variant of the library as a [BuildVariant] enum - */ - @JvmStatic - @Suppress("MemberVisibilityCanBePrivate") - public val buildVariant: BuildVariant = BuildVariant.valueOf(BUILD_VARIANT) - } + /** + * The timezone where the library was built. + * @return The timezone where the library was built as a [TimeZone] object + */ + @Suppress("MemberVisibilityCanBePrivate") + public override val buildTimeZone: TimeZone = TimeZone.of(BUILD_TIMEZONE) /** * This function initializes the Koin dependency injection framework, diff --git a/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/util/Util.kt b/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/util/Util.kt new file mode 100644 index 0000000000000000000000000000000000000000..02c44e97962f01dbfffd34e31569ca6947c3410c --- /dev/null +++ b/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/util/Util.kt @@ -0,0 +1,34 @@ +/* + * Designed and developed in 2022-2024 by William Walker (wnwalker@ucsc.edu) + * Copyright 2022-2024 The Regents of the University of California. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package edu.ucsc.its.temerity.util + +import edu.ucsc.its.temerity.extensions.datetime.DateTimeExt +import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalTime + +/** + * Get the current date as a [LocalDate] object + * @return The current date as a [LocalDate] object + */ +public fun currentDate(): LocalDate = DateTimeExt.currentDate() + +/** + * Get the current time as a [LocalTime] object + * @return The current time as a [LocalTime] object + */ +public fun currentTime(): LocalTime = DateTimeExt.currentTime()