chore: please the formatter
parent
2e6ac5cda6
commit
4fb6f629ac
|
@ -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 { '' }
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -37,7 +37,7 @@ fn test_next_simple() ! {
|
|||
|
||||
fn test_leading_star() {
|
||||
mut x := false
|
||||
|
||||
|
||||
parse_expression('*5 8') or { x = true }
|
||||
|
||||
assert x
|
||||
|
|
Loading…
Reference in New Issue