Lines 93-99
s/(\d{4})(\d{2})(\d{2})\s+(\d{2})(\d{2})(\d{2})/$1-$2-$3T$4:$5:$6/;
Link Here
|
93 |
|
93 |
|
94 |
=head2 output_pref |
94 |
=head2 output_pref |
95 |
|
95 |
|
96 |
$date_string = output_pref({ dt => $dt [, dateformat => $date_format, timeformat => $time_format, dateonly => 0|1 ] }); |
96 |
$date_string = output_pref({ dt => $dt [, dateformat => $date_format, timeformat => $time_format, dateonly => 0|1, as_due_date => 0|1 ] }); |
97 |
$date_string = output_pref( $dt ); |
97 |
$date_string = output_pref( $dt ); |
98 |
|
98 |
|
99 |
Returns a string containing the time & date formatted as per the C4::Context setting, |
99 |
Returns a string containing the time & date formatted as per the C4::Context setting, |
Lines 110-121
should be returned without the time.
Link Here
|
110 |
|
110 |
|
111 |
sub output_pref { |
111 |
sub output_pref { |
112 |
my $params = shift; |
112 |
my $params = shift; |
113 |
my ( $dt, $force_pref, $force_time, $dateonly ); |
113 |
my ( $dt, $force_pref, $force_time, $dateonly, $as_due_date ); |
114 |
if ( ref $params eq 'HASH' ) { |
114 |
if ( ref $params eq 'HASH' ) { |
115 |
$dt = $params->{dt}; |
115 |
$dt = $params->{dt}; |
116 |
$force_pref = $params->{dateformat}; # if testing we want to override Context |
116 |
$force_pref = $params->{dateformat}; # if testing we want to override Context |
117 |
$force_time = $params->{timeformat}; |
117 |
$force_time = $params->{timeformat}; |
118 |
$dateonly = $params->{dateonly} || 0; # if you don't want the hours and minutes |
118 |
$dateonly = $params->{dateonly} || 0; # if you don't want the hours and minutes |
|
|
119 |
$as_due_date = $params->{as_due_date} || 0; # don't display the hours and minutes if eq to 23:59 or 11:59 (depending the TimeFormat value) |
119 |
} else { |
120 |
} else { |
120 |
$dt = $params; |
121 |
$dt = $params; |
121 |
} |
122 |
} |
Lines 129-157
sub output_pref {
Link Here
|
129 |
|
130 |
|
130 |
my $time_format = $force_time || C4::Context->preference('TimeFormat'); |
131 |
my $time_format = $force_time || C4::Context->preference('TimeFormat'); |
131 |
my $time = ( $time_format eq '12hr' ) ? '%I:%M %p' : '%H:%M'; |
132 |
my $time = ( $time_format eq '12hr' ) ? '%I:%M %p' : '%H:%M'; |
132 |
|
133 |
my $date; |
133 |
if ( $pref =~ m/^iso/ ) { |
134 |
if ( $pref =~ m/^iso/ ) { |
134 |
return $dateonly |
135 |
$date = $dateonly |
135 |
? $dt->strftime("%Y-%m-%d") |
136 |
? $dt->strftime("%Y-%m-%d") |
136 |
: $dt->strftime("%Y-%m-%d $time"); |
137 |
: $dt->strftime("%Y-%m-%d $time"); |
137 |
} |
138 |
} |
138 |
elsif ( $pref =~ m/^metric/ ) { |
139 |
elsif ( $pref =~ m/^metric/ ) { |
139 |
return $dateonly |
140 |
$date = $dateonly |
140 |
? $dt->strftime("%d/%m/%Y") |
141 |
? $dt->strftime("%d/%m/%Y") |
141 |
: $dt->strftime("%d/%m/%Y $time"); |
142 |
: $dt->strftime("%d/%m/%Y $time"); |
142 |
} |
143 |
} |
143 |
elsif ( $pref =~ m/^us/ ) { |
144 |
elsif ( $pref =~ m/^us/ ) { |
144 |
|
145 |
$date = $dateonly |
145 |
return $dateonly |
|
|
146 |
? $dt->strftime("%m/%d/%Y") |
146 |
? $dt->strftime("%m/%d/%Y") |
147 |
: $dt->strftime("%m/%d/%Y $time"); |
147 |
: $dt->strftime("%m/%d/%Y $time"); |
148 |
} |
148 |
} |
149 |
else { |
149 |
else { |
150 |
return $dateonly |
150 |
$date = $dateonly |
151 |
? $dt->strftime("%Y-%m-%d") |
151 |
? $dt->strftime("%Y-%m-%d") |
152 |
: $dt->strftime("%Y-%m-%d $time"); |
152 |
: $dt->strftime("%Y-%m-%d $time"); |
153 |
} |
153 |
} |
154 |
|
154 |
|
|
|
155 |
if ( $as_due_date ) { |
156 |
$time_format eq '12hr' |
157 |
? $date =~ s| 11:59 PM$|| |
158 |
: $date =~ s| 23:59$||; |
159 |
} |
160 |
|
161 |
return $date; |
155 |
} |
162 |
} |
156 |
|
163 |
|
157 |
=head2 format_sqldatetime |
164 |
=head2 format_sqldatetime |