From: Robert Klemme Date: 2009-12-28T21:27:35+09:00 Subject: Re: unpack :( 2009/12/28 Brian Candler : > Brian Candler wrote: >>>> systemdate.unpack("nccccccAcc") >> => [2009, 12, 28, 11, 42, 40, 0, "+", 1, 0] >> >> i.e. 11:42:40.0 (tenths of a second) with a timezone of +01:00 > > Just to make this clear: you should not be using the "H" format > converter. "H" gives you ASCII hex representation, for example the byte > 0x07 is converted into the two ASCII characters "0" and "7", or vice > versa. > > What you appear to have is a binary string, and you want the byte 0x07 > to be converted to the number 7, or the pair of bytes 0x07 0xd9 to be > converted to the number 2009. These are the "c" and "n" formats > respectively. I am not so sure. He said > It's a hex string and It could be in these formats (for linux and > windows): > > 2009-12-28,11:37:25.0,+1:0 > 2009-12-28,11:53:34.0 If it is actually a string, a completely different tool might better suit the job: require 'date' [ '2009-12-28,11:37:25.0,+1:0', '2009-12-28,11:53:34.0', ].each do |str| dt = DateTime.strptime str, '%Y-%m-%d,%H:%M:%S' printf "%s -> %p (%s)\n", str, dt, dt end That version omits time zone information though. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/