Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/invoca/utils/time.rb

Overview

Invoca ::Time extensions

Instance Method Summary collapse

Instance Method Details

#beginning_of_hourObject



23
24
25
# File 'lib/invoca/utils/time.rb', line 23

def beginning_of_hour
  change(:min => 0, :sec => 0, :usec => 0)
end

#end_of_day_whole_secObject

usec can be bad because it isn’t preserved by MySQL



27
28
29
# File 'lib/invoca/utils/time.rb', line 27

def end_of_day_whole_sec # usec can be bad because it isn't preserved by MySQL
  change(:hour => 23, :min => 59, :sec => 59, :usec => 0)
end

#rfc3339msObject



9
10
11
# File 'lib/invoca/utils/time.rb', line 9

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

#to_msObject



3
4
5
# File 'lib/invoca/utils/time.rb', line 3

def to_ms
  @to_ms ||= (self.to_f * 1000).to_i
end

#whole_secObject



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

def whole_sec
  change(:usec => 0)
end