Skip to content

Commit

Permalink
new version with formatted time diff output
Browse files Browse the repository at this point in the history
  • Loading branch information
abhidsm committed Apr 4, 2011
1 parent 6c9f0fb commit a16fa3d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
16 changes: 16 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@ You can use the difference like:

diff[:year], diff[:month], diff[:week]


Formatted Time difference
-------------------------

%y - year
%M - month
%w - week
%d - day
%h - hour
%m - minute
%s - second

By default the format is '%y, %M, %w, %d and %h:%m:%s' this will return '1 year, 2 months, 3 weeks, 4 days and 12:05:52'.
You will get the result from the output hash, time_diff_components[:diff]

You can pass your own format as third parameter to this function.
19 changes: 17 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,28 @@ gem install time_diff

require 'time_diff'

diff = Time.diff(start_date_time, end_date_time)
time_diff_components = Time.diff(start_date_time, end_date_time)

This will return the hash of time difference in terms of years, month, week, day, hour, minute and second.

You can use the difference like:

diff[:year], diff[:month], diff[:week]
time_diff_components[:year], time_diff_components[:month], time_diff_components[:week]

==Formatted Time difference

%y - year
%M - month
%w - week
%d - day
%h - hour
%m - minute
%s - second

By default the format is '%y, %M, %w, %d and %h:%m:%s' this will return '1 year, 2 months, 3 weeks, 4 days and 12:05:52'.
You will get the result from the output hash, time_diff_components[:diff]

You can pass your own format as third parameter to this function.

== Contributing to time_diff

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
2.0.0

0 comments on commit a16fa3d

Please sign in to comment.