ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Can Ruby print out time difference (duration) readily?
by Jian Lin other posts by this author
Nov 5 2009 1:09AM messages near this date
[ANN] unicorn 0.94.0 - small fixes and new features | Re: Can Ruby print out time difference (duration) readily?
Can Ruby do something like this?

irb(main):001:0>  start = Time.now
=>  Thu Nov 05 01:02:54 -0800 2009

irb(main):002:0>  Time.now - start
=>  25.239

irb(main):003:0>  (Time.now - start).duration
=>  "25 seconds"
and similarly, report

23 minutes and 35 seconds
1 hour and 33 minutes
2 days and 3 hours
(either report the whole duration, up to how many seconds, or report up
to 2 numbers and units (if day and hour is reported, then no need to
tell how many minutes)
-- 
Posted via http://www.ruby-forum.com/.
Thread:
Jian Lin
Intransition
Phrogz
Ehsanul Hoque
Mark Thomas

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved