1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-10 10:49:39 +02:00

Kotlin conversion: SignatureSubpackets + subclasses

This commit is contained in:
Paul Schaub 2023-10-20 14:10:37 +02:00
parent 4fc513fa25
commit 0effc84fac
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
15 changed files with 777 additions and 1043 deletions

View file

@ -24,11 +24,21 @@ fun Date.plusSeconds(seconds: Long): Date? {
else Date(this.time + 1000 * seconds)
}
val Date.asSeconds: Long
get() = time / 1000
fun Date.secondsTill(later: Date): Long {
require(this <= later) {
"Timestamp MUST be before the later timestamp."
}
return later.asSeconds - this.asSeconds
}
/**
* Return a new [Date] instance with this instance's time floored down to seconds precision.
*/
fun Date.toSecondsPrecision(): Date {
return Date((time / 1000) * 1000)
return Date(asSeconds * 1000)
}
internal val parser: SimpleDateFormat