Skip to content

Instantly share code, notes, and snippets.

@skreuzer
Created December 28, 2009 17:20
Show Gist options
  • Save skreuzer/264787 to your computer and use it in GitHub Desktop.
Save skreuzer/264787 to your computer and use it in GitHub Desktop.
#
# Find Last Weekday of the Month
#
use DateTime;
my $dt = DateTime->last_day_of_month( year => 2009, month => 5 );
# Day 6 is Saturday, Day 7 is Sunday
while ( $dt->day_of_week >= 6 ) { $dt->subtract( days => 1 ) }
print "Last Weekday is ", $dt->ymd, "\n";
#
# Find Last Day of Month
#
$month = 05
$year = 2009;
my $lastday = POSIX::mktime(0, 0, 0, 0, $month-1+1, $year-1900, 0, 0, -1);
@_ = localtime($lastday);
print "Last Day of Month: $_[3]\n";
#
# Print yesterdays date
#
@T=localtime(time-86400);
printf("%02d/%02d/%02d",$T[4]+1,$T[3],($T[5]+1900)%100)
#
# Print tomorrows date:
#
@T=localtime(time+86400);
printf("%02d/%02d/%02d",$T[4]+1,$T[3],($T[5]+1900)%100)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment