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-160
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'; |
|
|
133 |
my $date = do { |
134 |
given ($pref) { |
135 |
when (/^iso/) { |
136 |
$dateonly |
137 |
? $dt->strftime("%Y-%m-%d") |
138 |
: $dt->strftime("%Y-%m-%d $time"); |
139 |
} |
140 |
when (/^metric/) { |
141 |
$dateonly |
142 |
? $dt->strftime("%d/%m/%Y") |
143 |
: $dt->strftime("%d/%m/%Y $time"); |
144 |
} |
145 |
when (/^us/) { |
146 |
$dateonly |
147 |
? $dt->strftime("%m/%d/%Y") |
148 |
: $dt->strftime("%m/%d/%Y $time"); |
149 |
} |
150 |
default { |
151 |
$dateonly |
152 |
? $dt->strftime("%Y-%m-%d") |
153 |
: $dt->strftime("%Y-%m-%d $time"); |
154 |
} |
132 |
|
155 |
|
133 |
given ($pref) { |
|
|
134 |
when (/^iso/) { |
135 |
return $dateonly |
136 |
? $dt->strftime("%Y-%m-%d") |
137 |
: $dt->strftime("%Y-%m-%d $time"); |
138 |
} |
139 |
when (/^metric/) { |
140 |
return $dateonly |
141 |
? $dt->strftime("%d/%m/%Y") |
142 |
: $dt->strftime("%d/%m/%Y $time"); |
143 |
} |
144 |
when (/^us/) { |
145 |
|
146 |
return $dateonly |
147 |
? $dt->strftime("%m/%d/%Y") |
148 |
: $dt->strftime("%m/%d/%Y $time"); |
149 |
} |
150 |
default { |
151 |
return $dateonly |
152 |
? $dt->strftime("%Y-%m-%d") |
153 |
: $dt->strftime("%Y-%m-%d $time"); |
154 |
} |
156 |
} |
|
|
157 |
}; |
155 |
|
158 |
|
|
|
159 |
if ( $as_due_date ) { |
160 |
$time_format eq '12hr' |
161 |
? $date =~ s| 11:59 PM$|| |
162 |
: $date =~ s| 23:59$||; |
156 |
} |
163 |
} |
157 |
return; |
164 |
|
|
|
165 |
return $date; |
158 |
} |
166 |
} |
159 |
|
167 |
|
160 |
=head2 format_sqldatetime |
168 |
=head2 format_sqldatetime |