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



25
26
27
# File 'lib/invoca/utils/time.rb', line 25

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



29
30
31
# File 'lib/invoca/utils/time.rb', line 29

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



11
12
13
# File 'lib/invoca/utils/time.rb', line 11

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

#to_msObject



5
6
7
# File 'lib/invoca/utils/time.rb', line 5

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

#whole_secObject



33
34
35
# File 'lib/invoca/utils/time.rb', line 33

def whole_sec
  change(:usec => 0)
end