public
Description: Convert string to minutes, and minutes to human readable string
Home | Edit | New

Home

Quite Simple.

It converts a string representing time in D H M to minutes.
Its used to simply store minutes in the database, but give the user a simple way to represent complex time.

It assumes 24 hours = 1day.

So


"2h".minutes => 60 "1d".minutes => 1440 "1d 1m".minutes => 1441 "1d 1h".minutes => 1500 "1m".minutes => 1

And you can convert back


1441.humanize => "1d 1m"
1.humanize => "1m"

And you can go back and forward to standardize the display to the user


"90m".minutes.humanize => "1h 30m"

Last edited by markgandolfo, Wed Jun 03 21:30:00 -0700 2009
Home | Edit | New
Versions: