### Home Classes Methods

### In Files

- lib/chronic/time.rb

### Parent

Object

### Methods

- ::could_be_hour?
- ::could_be_minute?
- ::could_be_second?
- ::could_be_subsecond?
- ::normalize_offset

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Chronic
- Chronic::Date
- Chronic::Grabber
- Chronic::Handler
- Chronic::Handlers
- Chronic::MiniDate
- Chronic::Numerizer
- Chronic::Ordinal
- Chronic::Parser
- Chronic::Pointer
- Chronic::Repeater
- Chronic::Scalar
- Chronic::Season
- Chronic::Separator
- Chronic::Sign
- Chronic::Span
- Chronic::Tag
- Chronic::Time
- Chronic::TimeZone
- Chronic::Token

No matching classes.

# Chronic::Time

### Constants

HOUR_SECONDS
MINUTE_SECONDS
SECOND_SECONDS
SUBSECOND_SECONDS

### Public Class Methods

could_be_hour?(hour) click to toggle source

Checks if given number could be hour

    # File lib/chronic/time.rb, line 9
    def self.could_be_hour?(hour)
      hour >= 0 && hour <= 24
    end

could_be_minute?(minute) click to toggle source

Checks if given number could be minute

    # File lib/chronic/time.rb, line 14
    def self.could_be_minute?(minute)
      minute >= 0 && minute <= 60
    end

could_be_second?(second) click to toggle source

Checks if given number could be second

    # File lib/chronic/time.rb, line 19
    def self.could_be_second?(second)
      second >= 0 && second <= 60
    end

could_be_subsecond?(subsecond) click to toggle source

Checks if given number could be subsecond

    # File lib/chronic/time.rb, line 24
    def self.could_be_subsecond?(subsecond)
      subsecond >= 0 && subsecond <= 999999
    end

normalize_offset(offset) click to toggle source

normalize offset in seconds to offset as string +mm:ss or -mm:ss

    # File lib/chronic/time.rb, line 29
    def self.normalize_offset(offset)
      return offset if offset.is_a?(String)
      offset = Chronic.time_class.now.to_time.utc_offset unless offset # get current system's UTC offset if offset is nil
      sign = '+'
      sign = '-' if offset < 0
      hours = (offset.abs / 3600).to_i.to_s.rjust(2,'0')
      minutes = (offset.abs % 3600).to_s.rjust(2,'0')
      sign + hours + minutes
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.