I am looking for a better way to do some rather simple date-arithmetic.
At the moment I am using the DateTime-Module but I just reinstalled it on a new system and I am shocked on how much dependencies it pulls in.
I know there is a plethora of date-modules on CPAN and as I am too lazy to check them all out myself I hope for some pointers for something more lightweight...
So my ideal solution would be using only core-modules while not getting too complicated or at least using modules that don't pull in half of cpan.
What I need is a logic that produces a date depending on the current day:
If the current day is a Thursday I want the date of the following day.
If the current day is a Friday I want the date of this day.
If the current day is anything else I want the date of the preceeding Friday.
Here is what I do at the monent:
Many thanks!use DateTime; my $td = DateTime->today; my $days_since_friday = ($td->day_of_week - 5) % 7; my $days_to_subtract = $days_since_friday == 6 ? -1 : $days_since_frid +ay; $td->subtract( days => $days_to_subtract ); print $td->strftime("%d%m%y");
In reply to date arithmetic by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |