|
Posted by Steve on 03/02/07 17:37
"J.O. Aho" <user@example.net> wrote in message
news:54r52qF227se8U1@mid.individual.net...
| J.O. Aho wrote:
| > J.O. Aho wrote:
| >> Brian wrote:
| >>> Hi all
| >>>
| >>>
| >>>
| >>> I'm trying to write a script that works out the day of week, goes
| >>> back to previous Monday, then removes a week and sets up 2 timestamps.
| >>>
| >>>
| >>>
| >>> EG, if the day was Wednesday 28 Feb 2007 then is would work out that
| >>> the Monday was the 26, then remove 7 days to give me my start data
| >>> and add 6 days to give me my end date. So for Wednesday 28 Feb 2007 I
| >>> should end up with Mon 19th Feb to Sun 26th Feb
| >>>
| >>>
| >>>
| >>> I have hit a problem, the way I am working it out all goes wrong at
| >>> the beginning of the month, bacuse of this
| >>
| >> Here is how you get the unixtime for Monday (00:00:00) and Sunday
| >> (23:59:59)
| >
| > I missed it was supposed to be a week earlier, it's just subtract 7 more
| > days from $frommonday.
|
| Steven shouldn't have praised me that much, he prolly wouldn't if he
noticed
| that I mixed up the signs and I shouldn't have subtracted, but added 7
more
| days to the $frommonday.
sure i would have (and do)...and, i did notice. that's just an oversite.
were there money on that, i'd have been pissed. ;^)
as it is, i'm more interested in seeing the different approaches people
take. yours is 3 lines of code, nice and concise. i opted for six
non-commented lines hoping the 'last monday' textual method would both
return the values expected and serve as commantary at the same time.
i like the way you've done it! the good news is, there are always more cats
than the almost infinite number of ways one could skin them. ;^)
cheers.
[Back to original message]
|