Open-source multiplayer game server compatible with the RuneScape client https://www.openrs2.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
openrs2/cli/src/main/kotlin/org/openrs2/cli/OptionExtensions.kt

17 lines
627 B

package org.openrs2.cli
import com.github.ajalt.clikt.core.BadParameterValue
import com.github.ajalt.clikt.parameters.options.NullableOption
import com.github.ajalt.clikt.parameters.options.RawOption
import com.github.ajalt.clikt.parameters.options.convert
import java.time.Instant
import java.time.OffsetDateTime
import java.time.format.DateTimeParseException
public fun RawOption.instant(): NullableOption<Instant, Instant> = convert({ "TIMESTAMP" }) {
try {
OffsetDateTime.parse(it).toInstant()
} catch (ex: DateTimeParseException) {
throw BadParameterValue("$it is not a valid timestamp")
}
}