parseTimeInterval

Converts a string to seconds

long
parseTimeInterval

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: long

The interval in seconds

Examples

Test.test!("==")(parseTimeInterval("1s"), 1);
Test.test!("==")(parseTimeInterval("1m"), 60);
Test.test!("==")(parseTimeInterval("2m"), 120);
Test.test!("==")(parseTimeInterval("1h"), 3_600);
Test.test!("==")(parseTimeInterval("2h"), 7_200);
Test.test!("==")(parseTimeInterval("1d"), 3600 * 24);
Test.test!("==")(parseTimeInterval("2d"), 3600 * 48);

Test.testThrown!(Exception)(parseTimeInterval(""), false);
Test.testThrown!(Exception)(parseTimeInterval("0s"), false);
Test.testThrown!(Exception)(parseTimeInterval("2x"), false);
Test.testThrown!(Exception)(parseTimeInterval("1xm"), false);

Meta