Module: JamfRubyExtensions::Time::Utils

Included in:
Time
Defined in:
lib/jamf/ruby_extensions/time/utils.rb

Instance Method Summary collapse

Instance Method Details

#j_msecInteger Also known as: jss_msec

Returns the milliseconds of the Time.

Returns:

  • (Integer)

    the milliseconds of the Time



31
32
33
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 31

def j_msec
  strftime('%L').to_i
end

#to_j_dateString Also known as: to_jss_date

Returns the Time formatted for a plain JSS XML date element.

Returns:

  • (String)

    the Time formatted for a plain JSS XML date element



45
46
47
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 45

def to_j_date
  strftime '%Y-%m-%d %H:%M:%S'
end

#to_j_epochInteger Also known as: to_jss_epoch

Returns The Time as a unix epoch with milliseconds appended.

Returns:

  • (Integer)

    The Time as a unix epoch with milliseconds appended



37
38
39
40
41
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 37

def to_j_epoch
  msec = strftime('%L').rjust(3, '0')
  epoch = strftime('%s')
  "#{epoch}#{msec}".to_i
end

#to_j_utcString Also known as: to_jss_utc

Returns the Time formatted for a JSS UTC XML date element.

Returns:

  • (String)

    the Time formatted for a JSS UTC XML date element



51
52
53
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 51

def to_j_utc
  strftime("%Y-%m-%dT%H:%M:%S.#{j_msec}%z")
end