11 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
26 #Get the database handle
27 my $dbh = C4::Context->dbh;
28 return C4::Context->preference('dateformat');
31 sub display_date_format
33 my $dateformat = get_date_format();
35 if ( $dateformat eq "us" )
39 elsif ( $dateformat eq "metric" )
43 elsif ( $dateformat eq "iso" )
49 return "Invalid date format: $dateformat. Please change in system preferences";
64 my $dateformat = get_date_format();
66 if ( $dateformat eq "us" )
68 Date_Init("DateFormat=US");
69 $olddate = ParseDate($olddate);
70 $newdate = UnixDate($olddate,'%m/%d/%Y');
72 elsif ( $dateformat eq "metric" )
74 Date_Init("DateFormat=metric");
75 $olddate = ParseDate($olddate);
76 $newdate = UnixDate($olddate,'%d/%m/%Y');
78 elsif ( $dateformat eq "iso" )
80 Date_Init("DateFormat=iso");
81 $olddate = ParseDate($olddate);
82 $newdate = UnixDate($olddate,'%Y-%m-%d');
86 return "Invalid date format: $dateformat. Please change in system preferences";
90 sub format_date_in_iso
100 my $dateformat = get_date_format();
102 if ( $dateformat eq "us" )
104 Date_Init("DateFormat=US");
105 $olddate = ParseDate($olddate);
107 elsif ( $dateformat eq "metric" )
109 Date_Init("DateFormat=metric");
110 $olddate = ParseDate($olddate);
112 elsif ( $dateformat eq "iso" )
114 Date_Init("DateFormat=iso");
115 $olddate = ParseDate($olddate);
122 $newdate = UnixDate($olddate, '%Y-%m-%d');