Skip to content

Commit

Permalink
Start fixing TimestampProcessor Time field handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
DivineThreepwood committed Apr 1, 2024
1 parent 55e7067 commit 2ae4157
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package org.openbase.jul.extension.type.processing

import com.google.protobuf.MessageOrBuilder
import org.openbase.jul.exception.CouldNotPerformException
import org.openbase.jul.exception.NotAvailableException
import org.openbase.jul.exception.NotSupportedException
import org.openbase.jul.exception.VerificationFailedException
import org.openbase.jul.exception.*
import org.openbase.jul.exception.printer.ExceptionPrinter
import org.openbase.jul.extension.protobuf.processing.ProtoBufFieldProcessor
import org.openbase.type.timing.TimestampType
Expand All @@ -21,9 +18,11 @@ import java.util.concurrent.TimeUnit
object TimestampProcessor {
const val SET: String = "set"
const val TIMESTAMP_NAME: String = "Timestamp"
const val TIME_NAME: String = "Time"

@JvmField
val TIMESTAMP_FIELD_NAME: String = TIMESTAMP_NAME.lowercase(Locale.getDefault())
val TIMESTAMP_FIELD_NAME: String = TIMESTAMP_NAME.lowercase()
val TIME_FIELD_NAME: String = TIME_NAME.lowercase()

@JvmStatic
val currentTimestamp: TimestampType.Timestamp
Expand Down Expand Up @@ -302,5 +301,7 @@ object TimestampProcessor {
}
}

val <M : TimestampOrBuilder> M.instant: Instant
get() = Instant.ofEpochMilli(TimestampProcessor.getTimestamp(this, TimeUnit.MILLISECONDS))
val <M : TimestampOrBuilder> M.instant: Instant?
get() = tryOrNull {
Instant.ofEpochMilli(TimestampProcessor.getTimestamp(this, TimeUnit.MILLISECONDS))
}

0 comments on commit 2ae4157

Please sign in to comment.