Module: TestBench::Telemetry::Controls::Time
- Defined in:
- lib/test_bench/telemetry/controls/time.rb
Defined Under Namespace
Modules: Elapsed, ISO8601, Offset, Random
Constant Summary collapse
- Other =
Offset
Class Method Summary collapse
- .example(offset_seconds: nil, offset_milliseconds: nil, offset_nanoseconds: nil) ⇒ Object
- .other_example ⇒ Object
- .random ⇒ Object
Class Method Details
.example(offset_seconds: nil, offset_milliseconds: nil, offset_nanoseconds: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/test_bench/telemetry/controls/time.rb', line 5 def self.example(offset_seconds: nil, offset_milliseconds: nil, offset_nanoseconds: nil) offset_nanoseconds ||= 0 if not offset_seconds.nil? offset_milliseconds = offset_seconds * 1_000 return example(offset_milliseconds:) elsif not offset_milliseconds.nil? offset_nanoseconds = offset_milliseconds * 1_000_000 return example(offset_nanoseconds:) end nanoseconds = 111_111_111 seconds = 11 minutes = 11 hours = 11 day = 1 month = 1 year = 2000 nanoseconds += offset_nanoseconds remaining_offset_seconds, nanoseconds = nanoseconds.divmod(1_000_000_000) microseconds = Rational(nanoseconds, 1_000) time = ::Time.utc(year, month, day, hours, minutes, seconds, microseconds) time + remaining_offset_seconds end |