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.
50 51 52 |
# File 'lib/jamf/ruby_extensions/time/utils.rb', line 50 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.
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_epoch ⇒ Integer Also known as: to_jss_epoch
Returns 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_utc ⇒ String Also known as: to_jss_utc
Returns 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 |