chore: please the formatter

Jef Roosens 2023-01-14 20:48:14 +01:00
parent 2f4acf59e3
commit a135068b31
3 changed files with 8 additions and 1 deletions

View File

@ -36,6 +36,7 @@ enum ParseError as u8 {
too_many_parts = 4 too_many_parts = 4
} }
// str returns the string representation of a ParseError.
fn (e ParseError) str() string { fn (e ParseError) str() string {
return match e { return match e {
.ok { '' } .ok { '' }

View File

@ -2,11 +2,13 @@ module cron
import time import time
// free the memory associated with the Expression.
[unsafe] [unsafe]
pub fn (ce &Expression) free() { pub fn (ce &Expression) free() {
C.ce_free(ce) C.ce_free(ce)
} }
// parse_expression parses a string into an Expression.
pub fn parse_expression(exp string) !&Expression { pub fn parse_expression(exp string) !&Expression {
out := C.ce_init() out := C.ce_init()
res := C.ce_parse_expression(out, exp.str) res := C.ce_parse_expression(out, exp.str)
@ -18,6 +20,8 @@ pub fn parse_expression(exp string) !&Expression {
return out return out
} }
// next calculates the next occurence of the cron schedule, given a reference
// point.
pub fn (ce &Expression) next(ref time.Time) time.Time { pub fn (ce &Expression) next(ref time.Time) time.Time {
st := SimpleTime{ st := SimpleTime{
year: ref.year year: ref.year
@ -39,6 +43,8 @@ pub fn (ce &Expression) next(ref time.Time) time.Time {
}) })
} }
// next_from_now calculates the next occurence of the cron schedule with the
// current time as reference.
pub fn (ce &Expression) next_from_now() time.Time { pub fn (ce &Expression) next_from_now() time.Time {
out := SimpleTime{} out := SimpleTime{}
C.ce_next_from_now(&out, ce) C.ce_next_from_now(&out, ce)

View File

@ -37,7 +37,7 @@ fn test_next_simple() ! {
fn test_leading_star() { fn test_leading_star() {
mut x := false mut x := false
parse_expression('*5 8') or { x = true } parse_expression('*5 8') or { x = true }
assert x assert x