Class: DateTime

Inherits:
Date
  • Object
show all
Includes:
Rounding::TimeExtensions
Defined in:
lib/rounding/core_ext/date_time.rb

Constant Summary collapse

UNIX_EPOCH =
2440588

Instance Method Summary collapse

Instance Method Details

#ceil_in_utc_to(step) ⇒ Object



40
41
42
# File 'lib/rounding/core_ext/date_time.rb', line 40

def ceil_in_utc_to(step)
  ceil_to(step, UNIX_EPOCH)
end

#ceil_to(step, around = -offset)) ⇒ Object



24
25
26
27
28
# File 'lib/rounding/core_ext/date_time.rb', line 24

def ceil_to(step, around=-offset)
  step   = decode_duration(step)
  around = decode_duration(around)
  super(step, around)
end

#floor_in_utc_to(step) ⇒ Object



36
37
38
# File 'lib/rounding/core_ext/date_time.rb', line 36

def floor_in_utc_to(step)
  floor_to(step, UNIX_EPOCH)
end

#floor_to(step, around = -offset)) ⇒ Object



18
19
20
21
22
# File 'lib/rounding/core_ext/date_time.rb', line 18

def floor_to(step, around=-offset)
  step   = decode_duration(step)
  around = decode_duration(around)
  super(step, around)
end

#round_in_utc_to(step) ⇒ Object



44
45
46
# File 'lib/rounding/core_ext/date_time.rb', line 44

def round_in_utc_to(step)
  round_to(step, UNIX_EPOCH)
end

#round_to(step, around = -offset)) ⇒ Object



30
31
32
33
34
# File 'lib/rounding/core_ext/date_time.rb', line 30

def round_to(step, around=-offset)
  step   = decode_duration(step)
  around = decode_duration(around)
  super(step, around)
end

#to_rObject



13
14
15
16
# File 'lib/rounding/core_ext/date_time.rb', line 13

def to_r
  no_offset = new_offset(0)
  no_offset.jd + no_offset.day_fraction
end