Blame view
tools/scripts/Date2txt.pl
871 Bytes
e6be5137b reinitialized pro... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
#!/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 "; } |