Gerillass

v2.1.0

Is Time

Type: Function
isTime();

Returns the value if it is a time in s or ms, and errors otherwise.

Arguments

NameTypeDescription
$valuetimeAccepts a duration such as 0.2s or 300ms, or 0.

Examples

Validating a duration argument in a mixin of your own.

Sass
@mixin fade($duration) {
  transition: opacity isTime($duration) ease;
}
.panel {
  @include fade(0.4s);
}
CSS
.panel {
  transition: opacity 0.4s ease;
}

What it refuses

Arguments are checked, so a wrong value stops the build with a message instead of quietly producing the wrong CSS.

Sass
.panel {
  transition-duration: isTime(400px);
}
Error: '400px' is not a valid time value. Time values must be specified in either seconds (s) or milliseconds (ms). Please try one of the following forms: '1s', '0.2s', or '3ms'