Class: CF::Date
Overview
Wrapper for CFDateRef
Class Method Summary collapse
-
.from_time(time) ⇒ CF::Date
constructs a CF::Date from a ruby time.
Instance Method Summary collapse
-
#to_time ⇒ Time
(also: #to_ruby)
returns a ruby Time instance corresponding to the same point in time.
Methods inherited from Base
check_cftype, #eql?, #equals?, #hash, #initialize, #inspect, #null?, #ptr=, #release, #release_on_gc, #retain, #to_cf, #to_ptr, typecast
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
19 20 21 |
# File 'lib/corefoundation/date.rb', line 19 def self.from_time(time) new(CF.CFDateCreate(nil, time.to_f - CF.kCFAbsoluteTimeIntervalSince1970)).release_on_gc end |
Instance Method Details
#to_time ⇒ Time Also known as: to_ruby
returns a ruby Time instance corresponding to the same point in time
26 27 28 |
# File 'lib/corefoundation/date.rb', line 26 def to_time Time.at(CF.CFDateGetAbsoluteTime(self) + CF.kCFAbsoluteTimeIntervalSince1970) end |