Time.minute
func Time.minute(t: Time.Timed): intTime.minute returns the minute of t, 0 to 59.
Details
- The minute is the one the wall clock shows, 0 to 59. On a
Time.ZonedDateTimeit depends on the zone: a zone with a half-hour or quarter-hour offset shows a different minute for the same instant.
Basic examples
Time.minute(Time.plainTime(14, 5)) // 5
Time.minute(Time.plainTime(hour: 9)) // 0
Time.minute(Time.plainTime(23, 59, 59)) // 59Call it through . on any value with a time:
let alarm = Time.plainTime(hour: 6, minute: 45)
alarm.minute() // 45Scope
A Time.PlainDateTime has the minute of its time:
let meeting = Time.plainDateTime(Time.plainDate(2026, 11, 11), Time.plainTime(10, 30))
meeting.minute() // 30A Time.ZonedDateTime has the minute its zone's wall clock shows:
let call = Time.parseZoned("2026-11-11T16:20:00+01:00[Europe/Stockholm]").unwrap()
call.minute() // 20A value typed Time.Timed may hold any of the three types with a time, and Time.minute takes it without narrowing. Pass Time.minute by name to read each one:
let lunch = Time.plainDateTime(Time.plainDate(2026, 11, 11), Time.plainTime(12, 15))
let launch = Time.parseZoned("2026-11-11T18:45:00Z[UTC]").unwrap()
let times: Array[Time.Timed] = [Time.plainTime(8, 5), lunch, launch]
times.map(Time.minute) // [5, 15, 45]Read the minute of a parsed time:
"07:42:10" | Time.parsePlainTime() | Result.map(Time.minute) // Ok{ value: 42 }Named arguments
The parameter is named t:
Time.minute(t: Time.plainTime(13, 37)) // 37Applications
Write a time as H:MM, padding the minute to two digits:
func clock(t: Time.PlainTime): string {
let mm = String.from(t.minute()).padStart(2, "0")
"${t.hour()}:${mm}"
}
clock(Time.plainTime(9, 5)) // "9:05"
clock(Time.plainTime(17, 30)) // "17:30"Count the minutes since midnight:
func minutesOfDay(t: Time.PlainTime): int {
t.hour() * 60 + t.minute()
}
minutesOfDay(Time.plainTime(0, 0)) // 0
minutesOfDay(Time.plainTime(8, 30)) // 510
minutesOfDay(Time.plainTime(23, 59)) // 1439Keep the events that start on the hour or the half hour:
let starts = [
Time.plainTime(9, 0),
Time.plainTime(9, 20),
Time.plainTime(10, 30),
Time.plainTime(11, 45),
]
println(starts.filter({ x.minute() % 30 == 0 }))[09:00:00, 10:30:00]Read the current minute. Time.nowIn gives the wall clock of a zone:
let now = Time.nowIn(Time.localZone())
println(now.minute())Properties and relations
Setting the minute with Time.with sets what Time.minute reads:
let t = Time.plainTime(10, 15)
for m in Array.range(0, 60) {
assert(t.with(minute: m).minute() == m)
}The minute stays 0 to 59 however many minutes are added:
let start = Time.plainTime(10, 15)
for i in Array.range(0, 200) {
let m = start.add(Time.duration(minutes: i)).minute()
assert(m >= 0 && m <= 59)
}Adding an hour leaves the minute as it was, and adding a minute carries into the hour at 59:
let t = Time.plainTime(9, 59)
assert(t.add(1h).minute() == 59)
assert(t.add(1m).minute() == 0)
assert(t.add(1m).hour() == 10)A Time.PlainDateTime and a Time.ZonedDateTime have the minute of their time:
let zoned = Time.parseZoned("2026-11-11T21:07:00+01:00[Europe/Stockholm]").unwrap()
let local = zoned.toPlainDateTime()
assert(zoned.minute() == zoned.toPlainTime().minute())
assert(local.minute() == local.toPlainTime().minute())Possible issues
A Time.Instant has no wall clock, so passing one is a compile error:
println(Time.minute(Time.now())) // error: cannot use Time.Instant where Time.Timed is expectedPut the instant in a zone first. The minute depends on the zone: the same instant is on the hour in UTC, at half past in Kolkata, and at a quarter to in Kathmandu:
let instant = Time.parseInstant("2026-11-11T09:00:00Z").unwrap()
let kolkata = Time.zone("Asia/Kolkata").unwrap()
let kathmandu = Time.zone("Asia/Kathmandu").unwrap()
instant.inZone(Time.utc).minute() // 0
instant.inZone(kolkata).minute() // 30
instant.inZone(kathmandu).minute() // 45A Time.PlainDate has no time:
println(Time.minute(Time.plainDate(2026, 11, 11))) // error: cannot use Time.PlainDate where Time.Timed is expectedTime.minute reads the clock, not a span. A duration literal keeps its minutes as written, and Time.part reads them:
let d = 90m
d.part(Time.Minute{}) // 90The seconds do not round the minute up. Round first with Time.round to read the nearest minute:
let t = Time.plainTime(10, 29, 50)
t.minute() // 29
t.round(Time.Minute{}).minute() // 30See also
Time.hour · Time.second · Time.with · Time.round · Time.plainTime · Time.inZone · Time.nowIn · Time.part · Time
