diff --git a/src/cron/expression.c.v b/src/cron/expression.c.v index 0698432..cd4b8b0 100644 --- a/src/cron/expression.c.v +++ b/src/cron/expression.c.v @@ -36,6 +36,7 @@ enum ParseError as u8 { too_many_parts = 4 } +// str returns the string representation of a ParseError. fn (e ParseError) str() string { return match e { .ok { '' } diff --git a/src/cron/expression.v b/src/cron/expression.v index 4a0d04c..c463d06 100644 --- a/src/cron/expression.v +++ b/src/cron/expression.v @@ -2,11 +2,13 @@ module cron import time +// free the memory associated with the Expression. [unsafe] pub fn (ce &Expression) free() { C.ce_free(ce) } +// parse_expression parses a string into an Expression. pub fn parse_expression(exp string) !&Expression { out := C.ce_init() res := C.ce_parse_expression(out, exp.str) @@ -18,6 +20,8 @@ pub fn parse_expression(exp string) !&Expression { 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 { st := SimpleTime{ 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 { out := SimpleTime{} C.ce_next_from_now(&out, ce) diff --git a/src/cron/expression_test.v b/src/cron/expression_test.v index c016b72..9863ef5 100644 --- a/src/cron/expression_test.v +++ b/src/cron/expression_test.v @@ -37,7 +37,7 @@ fn test_next_simple() ! { fn test_leading_star() { mut x := false - + parse_expression('*5 8') or { x = true } assert x