Date2txt.pl 871 Bytes
#!/usr/bin/perl

use strict;
use warnings;


while(<STDIN>){
	if(/\b\d{2}\/\d{2}\/(\d{2}|\d{4})\b/){
		$_ =~ s/\b(\d{2})\/(\d{2})\/(\d{2}|\d{4})\b/convertDate($1,$2,$3)/ge;
	}
	elsif(/\b\d{2}\/\d{2}\b/){
		$_ =~ s/\b(\d{2})\/(\d{2})\b/convertDate($1,$2)/ge
	}
	print $_;
}

sub convertDate
{
	my ($day, $month, $year) = @_;
	
	$day =~ s/01/premier/g;

	$month =~ s/01/janvier/g;
	$month =~ s/02/fe1vrier/g;
	$month =~ s/03/mars/g;
	$month =~ s/04/avril/g;
	$month =~ s/05/mai/g;
	$month =~ s/06/juin/g;
	$month =~ s/07/juillet/g;
	$month =~ s/08/aou3t/g;
	$month =~ s/09/septembre/g;
	$month =~ s/10/octobre/g;
	$month =~ s/11/novembre/g;
	$month =~ s/12/de1cembre/;

	if(!$year){
		$year = "";
	}
	elsif(length($year) == 2){
		if($year =~ /((0|1)\d)/){
			$year =~ s/((0|1)\d)/20$1/g;
		}
		else{
			$year =~ s/(\d\d)/19$1/g;
		}	
	}
	
	return " $day $month $year ";
}