you probably want to check out date::manip.
Failing that, I'd try mucking with the following POSIX compliant time formats.
%U week of year, Sunday as first day of week - 01 to 53 %W week of year, Monday as first day of week - 01 to 53
and do something like :
get today's date. get today's week of year. (WOY) while the current day's WOY = today's WOY retrieve and print articles
yeah.
why bother with epoch time when POSIX and Date::Manip are there to let you work on what you need to do, rather than figuring out mundane and error prone epoch time calculation?

Oh, a code sample? OK :
use POSIX; use strict; # # get epoch time and format to Week of Year. # my $today = time; my $current = strftime("%W",localtime($today)); # # Is today a sunday? # if (strftime("%w",localtime ($today))==0) { # # Yes, retrieve last week's news. # print "getting last week's news.\n"; } else { # # Nope, look for each day this week. # my $check = $current; while ($check==$current) { # # while WOYs are equal, retrieve that day's news. # print scalar(localtime($today)) , " is this week. Retrieving a +rticles.\n"; # # back a day. # $today -=86400; $check = strftime("%W",localtime($today)); } }

In reply to (boo) TIMTOWDI - munging dates and times by boo_radley
in thread There's More Than One Way To Do It by DarkBlue

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.