### Home Classes Methods

### In Files

- lib/facets/date.rb

### Parent

Object

### Methods

- ::local_time
- ::time_with_datetime_fallback
- ::utc_time
- #to_date
- #to_datetime

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Random
- Random::ArrayExtensions
- Random::HashExtensions
- Random::IntegerExtensions
- Random::NumericExtensions
- Random::RangeExtensions
- Random::StringExtensions
- Random::StringExtensions::Self
- FileUtils
- FileUtils::DryRun
- FileUtils::NoWrite
- FileUtils::Verbose
- Digest
- Digest::Class
- Digest::Instance
- Multiton
- Multiton::Inclusive
- Multiton::MetaMethods
- URI
- URI::Hash
- URI::Kernel
- Argvector
- Argvector
- ERB
- ERB::OpenTemplate
- Enumerable
- Enumerable::Arguments
- GetoptLong
- GetoptLong::DSL
- Memoizable
- Memoizable::Copy
- Numeric
- Numeric::Multipliers
- Object
- Object::ArgVector
- Timer
- Timer::Dummy
- Array
- BasicObject
- CGI
- Cloneable
- Continuation
- Date
- DateTime
- Equitable
- File
- Find
- Hash
- Instantiable
- Integer
- Interval
- Kernel
- Math
- Module
- Net
- NilClass
- NullClass
- OpEsc
- OpenStruct
- Pathname
- Platform
- Range
- RbConfig
- Set
- Shellwords
- String
- StringScanner
- Time
- Tuple
- YAML
- Zlib

No matching classes.

# Time

### Public Class Methods

local_time(*args) click to toggle source

    # File lib/facets/date.rb, line 356
    def self.local_time(*args)
      time_with_datetime_fallback(:local, *args)
    end

time_with_datetime_fallback(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0) click to toggle source

    # File lib/facets/date.rb, line 366
    def self.time_with_datetime_fallback(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0)
      ::Time.send(utc_or_local, year, month, day, hour, min, sec, usec)
    rescue
      offset = utc_or_local.to_sym == :local ? ::DateTime.local_offset : 0
      ::DateTime.civil(year, month, day, hour, min, sec, offset)
    end

utc_time(*args) click to toggle source

    # File lib/facets/date.rb, line 361
    def self.utc_time(*args)
      time_with_datetime_fallback(:utc, *args)
    end

### Public Instance Methods

to_date() click to toggle source

Converts a Time object to a Date, dropping hour, minute, and second precision.

    my_time = Time.now  # Mon Nov 12 22:59:51 -0500 2007
    my_time.to_date     # Mon, 12 Nov 2007

    your_time = Time.parse("1/13/2009 1:13:03 P.M.")  # Tue Jan 13 13:13:03 -0500 2009
    your_time.to_date                                 # Tue, 13 Jan 2009

    # File lib/facets/date.rb, line 384
    def to_date
      ::Date.new(year, month, day)
    end

to_datetime() click to toggle source

Converts a Time instance to a Ruby DateTime instance, preserving UTC offset.

    my_time = Time.now    # Mon Nov 12 23:04:21 -0500 2007
    my_time.to_datetime   # Mon, 12 Nov 2007 23:04:21 -0500

    your_time = Time.parse("1/13/2009 1:13:03 P.M.")  # Tue Jan 13 13:13:03 -0500 2009
    your_time.to_datetime                             # Tue, 13 Jan 2009 13:13:03 -0500

    # File lib/facets/date.rb, line 406
    def to_datetime
      ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400))
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.