Class: CF::Date

Inherits:
Base
  • Object
show all
Defined in:
lib/corefoundation/date.rb

Overview

Wrapper for CFDateRef

Instance Attribute Summary

Attributes inherited from Base

#ptr

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

check_cftype, #eql?, #equals?, finalize, #hash, #initialize, #null?, #to_cf, typecast

Methods included from Memory

#inspect, #release, #retain, #to_ptr

Methods included from Register

included, #register_type

Constructor Details

This class inherits a constructor from CF::Base

Class Method Details

.from_time(time) ⇒ CF::Date

constructs a CF::Date from a ruby time

Parameters:

  • time (Time)

Returns:

  • (CF::Date)

    a CF::Date instance that will be released on garbage collection



19
20
21
# File 'lib/corefoundation/date.rb', line 19

def self.from_time(time)
  new(CF.CFDateCreate(nil, time.to_f - CF.kCFAbsoluteTimeIntervalSince1970))
end

Instance Method Details

#to_timeTime Also known as: to_ruby

returns a ruby Time instance corresponding to the same point in time

Returns:

  • (Time)


26
27
28
# File 'lib/corefoundation/date.rb', line 26

def to_time
  Time.at(CF.CFDateGetAbsoluteTime(self) + CF.kCFAbsoluteTimeIntervalSince1970)
end