From: "Andrew S. Townley" Date: 2005-08-29T21:58:56+09:00 Subject: Re: millisec in strin representation of Time Hi folks, Did I miss something or did someone actually answer this part of the question? > Is there a way to use Time#strftime to generate a string that contains > milliseconds, I found myself hitting this same thing on Saturday (kinda ironic that was when the original post was sent to the list). What I want to do is something similar to the Java SimpleDateFormat where you can do something like: yyyy-MM-dd HH:mm:ss.SSS z I looked at the implementation of strftime in the ruby library and there's some unused letters for %, however what I want is to be able to specify the precision at the same time. I had considered hacking the implementation of strftime and sending it to the list, but I hadn't gotten there yet. I don't want to have to just do something like: "%d" % (time.usec / (10*precision)) if I can avoid it. Before I go off and implement something silly, does anyone have any ideas? Thanks in advance, ast On Sun, 2005-08-28 at 21:21, Joel VanderWerf wrote: > Kirk Haines wrote: > ... > > class Time > > class << Time > > alias :parse_old :parse > > def parse(date, now=Time.now) > > t = parse_old(date,now) > > d = Date._parse(date) > > t += d[:sec_fraction].to_f if d.has_key? :sec_fraction > t > > end > > end > > end > > If the _date_ arg doesn't have fractional seconds, then parse still > needs to return t. *************************************************************************************************** The information in this email is confidential and may be legally privileged. Access to this email by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system. ***************************************************************************************************