by saxindustries » Tue Aug 23, 2011 11:49 pm
I wrote a short perl program for figuring out what day you can say this to your kid, based on the subtracting 40 weeks idea:
Code: Select all
#!/usr/bin/perl -w
use strict;
use DateTime;
use DateTime::Format::Natural;
#ARGV[0] is your kid's birthday, you can just write it as "Aug 23, 2011"
#ARGV[1] is your birthday, same idea - just write it naturally
my $parser = DateTime::Format::Natural->new;
my $kid_bd = $parser->parse_datetime($ARGV[0]);
my $parent_bd = $parser->parse_datetime($ARGV[1]);
my $diff = $kid_bd->subtract_datetime($parent_bd);
my $doin_the_mom = $kid_bd->add($diff)->subtract(weeks => 40);
print $doin_the_mom->ymd."\n"
Example output:
Code: Select all
perl smbc-day.pl "August 23, 2011" "November 7, 1985"
2036-09-01
If my kid's born today, I get to brag about doing his mom at his age in September 2036.
I wrote a short perl program for figuring out what day you can say this to your kid, based on the subtracting 40 weeks idea:
[code]
#!/usr/bin/perl -w
use strict;
use DateTime;
use DateTime::Format::Natural;
#ARGV[0] is your kid's birthday, you can just write it as "Aug 23, 2011"
#ARGV[1] is your birthday, same idea - just write it naturally
my $parser = DateTime::Format::Natural->new;
my $kid_bd = $parser->parse_datetime($ARGV[0]);
my $parent_bd = $parser->parse_datetime($ARGV[1]);
my $diff = $kid_bd->subtract_datetime($parent_bd);
my $doin_the_mom = $kid_bd->add($diff)->subtract(weeks => 40);
print $doin_the_mom->ymd."\n"[/code]
Example output:
[code]perl smbc-day.pl "August 23, 2011" "November 7, 1985"
2036-09-01[/code]
If my kid's born today, I get to brag about doing his mom at his age in September 2036.