DateTime Archives

Happy Pi Day!

Did you know that 22/7 is actually a better approximation of pi than 3.14 is?

use DateTime;
use Math::Trig qw(pi);
use Test::More tests => 1;

my $today = DateTime::->now;
my $dm    = sprintf '%d/%d' => ($today->day, $today->month);

	abs( eval($dm) - pi ),
or diag("this test only passes on 22/7")

About Toby Inkster

user-pic I'm tobyink on CPAN, IRC and PerlMonks.