Can I create a ExperimentalTime TimeMark from an O...
# stdlib
r
Can I create a ExperimentalTime TimeMark from an OffsetDateTime using something like this or is it completely wrong usage/thinking around TimeSources?
Copy code
@OptIn(ExperimentalTime::class)
class DateTimeSource(val time: OffsetDateTime) : AbstractLongTimeSource(unit = DurationUnit.MILLISECONDS), TimeSource {
    override fun read(): Long {
        return time.toInstant().toEpochMilli()
    }
}
i
You can, but that time source will be pretty useless, as it never advances its time reading.
And use its
markAt(OffsetDateTime)
method to get a
TimeMark
corresponding to that date/time value value.
r
thanks, I had a hunch my implementation was wrong since its not a timesource but rather a fixed value