class CFPropertyList::CFDate
geht the timestamp or the Apple timestamp
directly, you get the Time class. If you access via get_value you either
the rest of the world uses seconds since 1970. So if you access value
This class holds Time values. While Apple uses seconds since 2001,
def get_value(format=CFDate::TIMESTAMP_UNIX)
def get_value(format=CFDate::TIMESTAMP_UNIX) if(format == CFDate::TIMESTAMP_UNIX) then return @value.to_i else return @value.to_f - CFDate::DATE_DIFF_APPLE_UNIX end end
def initialize(value = nil,format=CFDate::TIMESTAMP_UNIX)
def initialize(value = nil,format=CFDate::TIMESTAMP_UNIX) if(value.is_a?(Time) || value.nil?) then @value = value.nil? ? Time.now : value else set_value(value,format) end end
def set_value(value,format=CFDate::TIMESTAMP_UNIX)
def set_value(value,format=CFDate::TIMESTAMP_UNIX) if(format == CFDate::TIMESTAMP_UNIX) then @value = Time.at(value) else @value = Time.at(value + CFDate::DATE_DIFF_APPLE_UNIX) end end
def to_binary(bplist)
def to_binary(bplist) return bplist.date_to_binary(@value) end
def to_xml
def to_xml return LibXML::XML::Node.new('date') << LibXML::XML::Node.new_text(CFDate::date_string(@value)) end