Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Yesterday Date

by moritz (Cardinal)
on Feb 04, 2008 at 19:57 UTC ( [id://666076]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Yesterday Date
in thread Yesterday Date

$d-- is short for $d = $d -1, that is "subtract one from $d".

Date::Simple provides a date object, and you can add and subtract number from that, so today() - 1 is yesterday.

Then it decreases the value by one while the day of week is 0 (Sunday) or 6 (Saturday).

Replies are listed 'Best First'.
Re^4: Yesterday Date
by Anonymous Monk on Feb 04, 2008 at 20:08 UTC
    OK, it could be written like:
    if( ($d->day_of_week == 0) ||( $d->day_of_week == 6)){ $d = $d -1; print $d; }
      I guess I would have to add
      $d = $d -1; if( ($d->day_of_week == 0) ||( $d->day_of_week == 6)){ $d = $d -1; print $d; }
      before!
        Nope. You added two bugs

        If you start on a Monday, that'll give you the Saturday. That's why a loop was used.

        If you start on a day other than Sunday or Monday, it won't print anything. That's why the print was outside the loop.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://666076]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-03-28 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found