#!/usr/bin/perl

# Yesterday's Date v1.0 by Will Green
# Find the date of yesterday, today and tomorrow using Perl
# Taken from http://flux.org.uk/tech/2006/01/yesterdays_date_in_perl.html

# This code is dedicated to the public domain by Will Green. Anyone is
# free to copy, modify, publish, use, compile, sell, or distribute
# this code, either in source code form or as a compiled binary, for
# any purpose, commercial or non-commercial, and by any means.

use strict;
use warnings;

# today
my ($year, $month, $day) = (localtime)[5,4,3];

# yesterday
my ($yYear, $yMonth, $yDay) = (localtime(time - 24 * 60 * 60))[5,4,3];

# tomorrow
my ($tYear, $tMonth, $tDay) = (localtime(time + 24 * 60 * 60))[5,4,3];

# Perl years begin at 1900
$year += 1900;
$yYear += 1900;
$tYear += 1900;

# Perl months begin at 0
$month++;
$yMonth++;
$tMonth++;

print "Today is $year-$month-$day.\n";
print "Yesterday was $yYear-$yMonth-$yDay.\n";
print "Tomorrow will be $tYear-$tMonth-$tDay.\n";