[wplug] Determine the "Last Full Week" of the month

DK wplug at curlynoodle.com
Wed Oct 20 09:48:49 EDT 2010


On Wed, Oct 20, 2010 at 9:37 AM, Kevin Squire <gentgeen at wikiak.org> wrote:
> I have to work out a script (prefer bash in this case, but any will
> work) for work that will run on the 1 day of the week (sunday) but ONLY
> if it is the last full week of the month.
>
> For now I am only focusing on months with 31 days.  (by some luck,
> the only months I actually have to run this thing all have 31 days).
>
> If anyone has something already ... great... could you please share.
>
> Here is the logic I am going for now (and my question).. Does this
> logic seem right?
>
>  a) The latest possible date is the 25th .. anything after the 25th,
>  and there are not enough days to make a full week.
>  b) The earliest possible date is the 19th... anything before the 19th
>  would mean there is at least another full week.
>  c) Have a cron entry that runs from the 19th to the 25th of each month
>  d) Script checks if month has 31 days AND if "TODAY" is sunday AND
>  if "TODAY + 7" is still within this month. (if all true - process, if
>  any false - exit)


I think "TODAY + 7" would take you to the next Sunday, thereby the
next calendar week.  Might this be "TODAY + 6" to ensure you stay
within the same calendar week; i.e. Sunday to Saturday?

Regards,
Dave


More information about the wplug mailing list