%Q of DateTime#strftime not working

The rdoc says the following about the %Q directive:

%Q - Number of microseconds since 1970-01-01 00:00:00 UTC.

However, it seems to return the number of milliseconds instead.

1.9.3p194 :067 > now = DateTime.now
=> #<DateTime: 2012-08-03T17:43:10-07:00
((2456144j,2590s,721033000n),-25200s,2299161j)>
1.9.3p194 :068 > now.strftime("%s")
=> “1344040990”
1.9.3p194 :069 > now.strftime("%Q")
=> “1344040990721”
1.9.3p194 :070 > now.to_time.usec
=> 721033

As you can tell, the ‘now’ object does have microsecond accuracy. So why
doesn’t %Q work as advertised?

Am 04.08.2012 02:45, schrieb Jingjing D.:

=> “1344040990”
1.9.3p194 :069 > now.strftime("%Q")
=> “1344040990721”
1.9.3p194 :070 > now.to_time.usec
=> 721033

As you can tell, the ‘now’ object does have microsecond accuracy. So why
doesn’t %Q work as advertised?

It’s a bug in the documentation, it should read
“Number of milliseconds”.

I already submitted a patch.

unknown wrote in post #1071297:

Am 04.08.2012 02:45, schrieb Jingjing D.:

=> “1344040990”
1.9.3p194 :069 > now.strftime("%Q")
=> “1344040990721”
1.9.3p194 :070 > now.to_time.usec
=> 721033

As you can tell, the ‘now’ object does have microsecond accuracy. So why
doesn’t %Q work as advertised?

It’s a bug in the documentation, it should read
“Number of milliseconds”.

I already submitted a patch.

Thanks for confirming.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs