I'm wondering what other ways might you (better) obtain the number of days since monday (and friday for that matter) of the previous week?
use Time::ParseDate;
# ...
# use some logic to find beginning of last week
# note: (localtime)[6] = wday (0-6) where 0 = Sunday
my($today) = (localtime)[6];
my($monday_lastw) = { # figure out days since monday of last week
0 => 6,
1 => 7,
2 => 8,
3 => 9,
4 => 10,
5 => 11,
6 => 12,
}->{ $today };
my($saturday_lastw) = $monday_lastw - 6; # (days since sat. of last wk
+)
# get unix timestamp of the date on /monday/ of last week
# (first second of last week)
push(@parms, (parsedate(qq{$monday_lastw days ago 00:00:00}))[0]);
# get unix timestamp of the date on /saturday/ of last week
# (last second of last week)
push(@parms, (parsedate(qq{$saturday_lastw days ago 23:59:59}))[0]);
--
Tommy Butler, a.k.a.
Tommy
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.