module
VirtualDate::SecondsSpan
Overview
Renders and parses a Time::Span as a number of seconds.
Whole spans are written as plain integers. Sub-second spans keep their
fractional part, so that e.g. a shift of 500 milliseconds survives a
round-trip instead of truncating to 0 -- which would silently read back
as "no shift at all".
Defined in:
virtualdate.crConstant Summary
-
PATTERN =
/\A-?\d+(?:\.\d+)?\z/
Class Method Summary
-
.from_node(node : YAML::Nodes::Node) : Time::Span
Returns the
Time::Spannodecarries, raising at the node's own position when it holds anything else. -
.from_scalar?(value : String) : Time::Span | Nil
Returns the
Time::Spanvaluedenotes, ornilif it is not a number. -
.to_scalar(value : Time::Span) : String
Returns
valuerendered as a (possibly fractional) number of seconds.
Class Method Detail
Returns the Time::Span node carries, raising at the node's own
position when it holds anything else.
Returns the Time::Span value denotes, or nil if it is not a number.
Returns value rendered as a (possibly fractional) number of seconds.