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



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

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



64
65
66
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 64

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



56
57
58
59
60
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 56

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



70
71
72
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 70

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