- my $dateformat = get_date_format();
-
- if ( $dateformat eq "us" )
- {
- Date_Init("DateFormat=US");
- $olddate = ParseDate($olddate);
- $newdate = UnixDate($olddate,'%m/%d/%Y');
- }
- elsif ( $dateformat eq "metric" )
- {
- Date_Init("DateFormat=metric");
- $olddate = ParseDate($olddate);
- $newdate = UnixDate($olddate,'%d/%m/%Y');
- }
- elsif ( $dateformat eq "iso" )
- {
- Date_Init("DateFormat=iso");
- $olddate = ParseDate($olddate);
- $newdate = UnixDate($olddate,'%Y-%m-%d');
- }
- else
- {
- return "Invalid date format: $dateformat. Please change in system preferences";
- }
+# warn $olddate;
+# $olddate=~s#/|\.|-##g;
+ my ($year,$month,$day)=Parse_Date($olddate);
+ ($year,$month,$day)=split /-|\/|\.|:/,$olddate unless ($year && $month);
+# warn "$olddate annee $year mois $month jour $day";
+ if ($year>0 && $month>0){
+ my $dateformat = get_date_format();
+ $dateformat="metric" if (index(":",$olddate)>0);
+ if ( $dateformat eq "us" )
+ {
+ $newdate = sprintf("%02d/%02d/%04d",$month,$day,$year);
+ }
+ elsif ( $dateformat eq "metric" )
+ {
+ $newdate = sprintf("%02d/%02d/%04d",$day,$month,$year);
+ }
+ elsif ( $dateformat eq "iso" )
+ {
+ # Date_Init("DateFormat=iso");
+ $newdate = sprintf("%04d-%02d-%02d",$year,$month,$day);
+ }
+ else
+ {
+ return "Invalid date format: $dateformat. Please change in system preferences";
+ }
+# warn "newdate :$newdate";
+ }
+ return $newdate;