Mighty Perlmonks,

I have an x amount of seconds and would like to print it in a smart, human readable and intuitive format:

For instance:
# no need to write days, hours, seconds but # write minute in singular $ perl nice-epoch 60 1 minute # both second and minute is written singular $ perl nice-epoch 61 1 minute, 1 second # write minute in singular $ perl nice-epoch 62 in 1 minute, 2 seconds # no need to write days/hours or seconds but # write seconds in plural $ perl nice-epoch 120 in 2 minutes # no need to write hours, minutes, seconds $ perl nice-epoch 65400005465 in 756944 days

I tried to write something like that on my own based on 101511 but with all the plural/singular, is it zero or not it gets endless complicated and I wonder if any of you could recommend a already existing module.

Rakzer

In reply to smart human readable time epoch by rakzer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.