Class: Time

Inherits:
Object show all
Defined in:
lib/sixarm_ruby_ramp/time.rb

Overview

Time extensions

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.packString

Shorthand for Time.now.pack

Examples:

Time.pack
=> "20101231125959" 

Returns:



57
58
59
# File 'lib/sixarm_ruby_ramp/time.rb', line 57

def self.pack
  now.pack
end

.stampString

Shorthand for Time.now.stamp

Examples:

Time.stamp
 => "2010-12-31 12:59:59Z" 

Returns:



31
32
33
# File 'lib/sixarm_ruby_ramp/time.rb', line 31

def self.stamp
  now.stamp
end

Instance Method Details

#packString

The time is converted to UTC.

Examples:

Time.now.pack
=> "20101231125959" 

Returns:

  • (String)

    time packed into a short string: “YYYYMMDDHHMMSS”



44
45
46
# File 'lib/sixarm_ruby_ramp/time.rb', line 44

def pack
  getutc.strftime('%Y%m%d%H%M%S')
end

#stampString

This standard format is specified in IETF RFC 3339 and ISO 8601.

Examples:

Time.now.stamp 
=> "2010-12-31 12:59:59Z" 

Returns:

  • (String)

    a time stamp string in standard format: “YYYY-MM-DD HH:MM:SSZ”

See Also:



18
19
20
# File 'lib/sixarm_ruby_ramp/time.rb', line 18

def stamp
  getutc.strftime('%Y-%m-%d %H:%M:%SZ')
end