Is it possible to convert Array having binary or hex values stored as each element into 64bit Double Mac Absolute Time?
When I inspect array using p var_bytes
console shows following output.
\000\000\000\000\000\000\000\000\000\000\000\234\225x\266A\000\000\000\345\005\230\264
Is it possible to convert above array elements in 64bit Double Mac Absolute Time as a string?
My code is following just a simple do..end
puts "\nClose off the page header#{y.unpack("n")}\n"
z.scan(/(.{8})(.{8})(.{4})(.{4})(.{4})(.{4})(.{8})(.{8})(.{8})(.*\w)/m).each do |j,k,l,m,n,o,p,q,r,s|
puts "\nContent1#{j.unpack("n")}\n"
puts "\nContent2:#{k.unpack("n")}\n"
puts "\nContent3:#{l.unpack("n")}\n"
puts "\nContent4:#{m.unpack("n")}\n"
puts "\nContent5:#{n.unpack("n")}\n"
puts "\nContent6:#{o.unpack("n")}\n"
puts "\nContent7:#{p.unpack("n")}\n"
expdt = Time.at((q.unpack("L"))[0])
createdt = Time.at((r.unpack("L"))[0])
puts "Date1:\n#{expdt}\n"
puts "\nDate2:\n#{createdt}\n"
puts "\nCookie:\n"
puts s.split(/\0/m)
end
end
what will the simple way to convert this negative values to positive so Time.at wont give error and then convert it according to MAC Epoch time?
Try this:
where
bin
is an 8-byte representation of a double precision float.you may need to change "D" to "E" or "G" depending on where you are getting your data from. check the
unpack
docs for details.