Coverage Summary for Class: Timestamp (cloud.mindbox.mobile_sdk.models)
| Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| Timestamp |
50%
(2/4)
|
|
50%
(2/4)
|
57.9%
(11/19)
|
| Timestamp$Companion |
100%
(1/1)
|
|
100%
(1/1)
|
100%
(1/1)
|
| Total |
60%
(3/5)
|
|
60%
(3/5)
|
60%
(12/20)
|
package cloud.mindbox.mobile_sdk.models
import cloud.mindbox.mobile_sdk.convertToString
import cloud.mindbox.mobile_sdk.convertToZonedDateTimeAtUTC
import org.threeten.bp.Instant
/**
* Represents a specific point in time as milliseconds since the Unix epoch (January 1, 1970, 00:00:00 UTC)
*/
@JvmInline
internal value class Timestamp(val ms: Long) {
operator fun plus(milliseconds: Long): Timestamp = Timestamp(ms + milliseconds)
operator fun minus(timestamp: Timestamp): Timestamp = Timestamp(ms - timestamp.ms)
companion object {
val ZERO: Timestamp = Timestamp(0L)
}
}
internal fun Long.toTimestamp(): Timestamp = Timestamp(this)
internal fun Timestamp.convertToIso8601String(): String {
return Instant.ofEpochMilli(ms)
.convertToZonedDateTimeAtUTC()
.convertToString()
}