Here's the countdown to U1E9 used by my home page.

I include it as an example of formatting a date nicely, and to raise awareness of this critical issue for Unix systems: when the date rolls over to be one billion seconds (coming up soon!).

I was prompted to post this in response to the thread going on about nice date formatting.

#!/usr/bin/perl -w use strict; my $COUNT_TO = 1e9; my @TIME_UNITS = ( [ year => 365.25 * 24 * 60 * 60 ], [ week => 7 * 24 * 60 * 60 ], [ day => 24 * 60 * 60 ], [ hour => 60 * 60 ], [ minute => 60 ], [ second => 1 ], ); print "Content-type: text/plain\n\n"; my $delta = $COUNT_TO - time; $delta = 0 if $delta < 0; my @items = map { my ($unit, $secs) = @$_; my $count = int($delta/$secs); $delta -= $count * $secs; $count ? $count == 1 ? "1 $unit" : "$count ${unit}s" : (); } @TIME_UNITS; ## splice @items, 3 if @items > 3; @items = q(not very long) unless @items; my $relative = @items > 2 ? join(", ", @items[0..$#items-1], "and $items[-1]") : @items > 1 ? "$items[0] and $items[1]" : $items[0]; print $relative;

In reply to Countdown to U1E9 by merlyn

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.