Module: JamfRubyExtensions::Time::Utils
- Included in:
- Time
- Defined in:
- lib/jamf/ruby_extensions/time/utils.rb
Instance Method Summary collapse
-
#j_msec ⇒ Integer
(also: #jss_msec)
The milliseconds of the Time.
-
#to_j_date ⇒ String
(also: #to_jss_date)
The Time formatted for a plain JSS XML date element.
-
#to_j_epoch ⇒ Integer
(also: #to_jss_epoch)
The Time as a unix epoch with milliseconds appended.
-
#to_j_utc ⇒ String
(also: #to_jss_utc)
The Time formatted for a JSS UTC XML date element.
Instance Method Details
#j_msec ⇒ Integer Also known as: jss_msec
Returns the milliseconds of the Time.
49 50 51 |
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 49 def j_msec strftime('%L').to_i end |
#to_j_date ⇒ String Also known as: to_jss_date
Returns the Time formatted for a plain JSS XML date element.
63 64 65 |
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 63 def to_j_date strftime '%Y-%m-%d %H:%M:%S' end |
#to_j_epoch ⇒ Integer Also known as: to_jss_epoch
Returns The Time as a unix epoch with milliseconds appended.
55 56 57 58 59 |
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 55 def to_j_epoch msec = strftime('%L').rjust(3, '0') epoch = strftime('%s') "#{epoch}#{msec}".to_i end |
#to_j_utc ⇒ String Also known as: to_jss_utc
Returns the Time formatted for a JSS UTC XML date element.
69 70 71 |
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 69 def to_j_utc strftime("%Y-%m-%dT%H:%M:%S.#{j_msec}%z") end |