Module: PuppetX::SLURM::Util
- Defined in:
- lib/puppet_x/slurm/util.rb
Overview
Module for shared type configs
Class Method Summary collapse
Class Method Details
.parse_datetime(value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/puppet_x/slurm/util.rb', line 16 def self.parse_datetime(value) m = value.match(%r{^([0-9]{4})-([0-9]{2})-([0-9]{2})(?:T([0-9]{2}):([0-9]{2})(?::([0-9]{2})?)?)?$}) return nil if m.nil? year = m[1] month = m[2] day = m[3] hour = m[4] minute = m[5] seconds = m[6] datetime = [year, month, day, hour, minute, seconds] datetime end |
.parse_time(value) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/puppet_x/slurm/util.rb', line 5 def self.parse_time(value) m = value.match(%r{^(?:([0-9]+)-)?(?:([0-9]+):)?([0-9]+):([0-9]+)$}) return nil if m.nil? days = m[1].nil? ? 0 : m[1].to_i hours = m[2].nil? ? 0 : m[2] minutes = m[3] seconds = m[4] time = [days, hours, minutes, seconds] time end |