Module: ChronoLogger::Period

Included in:
TimeBasedLogDevice
Defined in:
lib/chrono_logger.rb

Constant Summary collapse

DAILY =
1
SiD =
24 * 60 * 60

Instance Method Summary collapse

Instance Method Details

#determine_period(format) ⇒ Object


30
31
32
33
34
35
36
37
38
# File 'lib/chrono_logger.rb', line 30

def determine_period(format)
  case format
  when /%[SscXrT]/ then nil     # seconds
  when /%[MR]/ then nil         # minutes
  when /%[HklI]/ then nil       # hours
  when /%[dejDFvx]/ then DAILY
  else nil
  end
end

#next_start_period(now, period) ⇒ Object


40
41
42
43
44
45
46
47
# File 'lib/chrono_logger.rb', line 40

def next_start_period(now, period)
  case period
  when DAILY
    Time.mktime(now.year, now.month, now.mday) + SiD
  else
    nil
  end
end