in reply to Re: Is there an easy way to get the start date of the current week?
in thread Is there an easy way to get the start date of the current week?
I just wrote another message in which I mention rarely using the components from list-context localtime(), except to feed into strftime(). This is one of those rare situations which call for using the components. In scalar context, localtime() gives you a fully formatted date-time string, but in list context it returns:
So rather than generating a date string "Sat Aug 21 22:00:53 2010" and then parsing it with a regex ( not even substr()! .. shocking! ), why not use the day of the week component .... 0 == Sunday through to 6 == Saturday.my ( $seconds, $minutes, $hours, $day_of_month, $month_idx, $years_since_1900, $day_of_week_number, $day_of_year, $id_dst ) = localtime($now);
$now -= 43200 while (localtime($now))[6]; # count back half days till +Sunday
--
TTTATCGGTCGTTATATAGATGTTTGCA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Is there an easy way to get the start date of the current week?
by BrowserUk (Patriarch) on Aug 22, 2010 at 03:02 UTC |