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.cr

Constant Summary

PATTERN = /\A-?\d+(?:\.\d+)?\z/

Class Method Summary

Class Method Detail

def self.from_node(node : YAML::Nodes::Node) : Time::Span #

Returns the Time::Span node carries, raising at the node's own position when it holds anything else.


[View source]
def self.from_scalar?(value : String) : Time::Span | Nil #

Returns the Time::Span value denotes, or nil if it is not a number.


[View source]
def self.to_scalar(value : Time::Span) : String #

Returns value rendered as a (possibly fractional) number of seconds.


[View source]