Dates, instants and clocks in Raven.
func ShowCurrentTime() {
let clock: Clock = SystemClock()
let instant = clock.Now
let local = instant.ToLocalDateTime()
WriteLine(local.Date.Year)
WriteLine(local.Time.Hour)
}This helper reads the host clock and prints the local year and hour; those values naturally vary. The complete sample also uses a fixed Clock to check deterministic Instant and Duration comparisons.
Behavior and limits.
.NET already separates DateOnly and TimeOnly and supports injectable time through TimeProvider. This API starts with those distinctions and typed validation outcomes. The current local conversion uses host settings; it is not a general timezone or calendar API.
Detailed contract and comparisons →PROPOSED DIRECTION
Where we’re heading.
The proposals add timezone rules, calendar-aware values and presentation through globalization. More types can make distinctions clear but bring data and conversion obligations. Formatting, parsing and culture behavior remain separate work.
Related proposals and open questions →What would you try?
Bring a small use case, the code you tried and the behavior you expected. Which part of this contract helps, and which part should change?
Share feedback on GitHub ↗