Skip to content

Commit

Permalink
std/time: add the Str method to Weekday
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Nov 21, 2024
1 parent c0fdfee commit c790f44
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions std/time/time.jule
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ fn daysBefore(m: Month): int {
// Specifies a day of the week (Sunday = 0, ...).
type Weekday: int

impl Weekday {
// Returns the English name of the day ("Sunday", "Monday", ...).
fn Str(self): str {
if Sunday <= self && self <= Saturday {
ret longDayNames[self]
}
mut buf := make([]byte, 20)
mut n := fmtInt(buf, u64(self))
ret "%!Weekday(" + str(buf[n:]) + ")"
}
}

const Sunday = Weekday(0)
const Monday = Weekday(1)
const Tuesday = Weekday(2)
Expand Down

0 comments on commit c790f44

Please sign in to comment.