isTimeInterval

Checks if a string can be converted to a time interval

bool
isTimeInterval

Parameters

value cstring

a string containing an integer and the first leter of a time unit. The supported units are minutes, hours and days.

Return Value

Type: bool

true, if the string is a valid interval

Examples

Test.test!("==")(isTimeInterval(""), false);
Test.test!("==")(isTimeInterval("1s"), true);
Test.test!("==")(isTimeInterval("1m"), true);
Test.test!("==")(isTimeInterval("2m"), true);
Test.test!("==")(isTimeInterval("1h"), true);
Test.test!("==")(isTimeInterval("2h"), true);
Test.test!("==")(isTimeInterval("1d"), true);
Test.test!("==")(isTimeInterval("2d"), true);

Test.test!("==")(isTimeInterval("1x"), false);
Test.test!("==")(isTimeInterval("2xm"), false);

Meta