|
Lines 144-150
sub addDate {
Link Here
|
| 144 |
|
144 |
|
| 145 |
$unit ||= 'days'; # default days ? |
145 |
$unit ||= 'days'; # default days ? |
| 146 |
my $dt; |
146 |
my $dt; |
| 147 |
|
|
|
| 148 |
if ( $unit eq 'hours' ) { |
147 |
if ( $unit eq 'hours' ) { |
| 149 |
# Fixed for legacy support. Should be set as a branch parameter |
148 |
# Fixed for legacy support. Should be set as a branch parameter |
| 150 |
my $return_by_hour = 10; |
149 |
my $return_by_hour = 10; |
|
Lines 154-160
sub addDate {
Link Here
|
| 154 |
# days |
153 |
# days |
| 155 |
$dt = $self->addDays($startdate, $add_duration); |
154 |
$dt = $self->addDays($startdate, $add_duration); |
| 156 |
} |
155 |
} |
| 157 |
|
|
|
| 158 |
return $dt; |
156 |
return $dt; |
| 159 |
} |
157 |
} |
| 160 |
|
158 |
|
|
Lines 206-225
sub addDays {
Link Here
|
| 206 |
} |
204 |
} |
| 207 |
} |
205 |
} |
| 208 |
|
206 |
|
| 209 |
} else { # Days or Datedue |
207 |
} else { # Days, Datedue or Dayweek |
| 210 |
# use straight days, then use calendar to push |
208 |
# use straight days, then use calendar to push |
| 211 |
# the date to the next open day if Datedue |
209 |
# the date to the next open day as appropriate |
|
|
210 |
# if Datedue or Dayweek |
| 212 |
$base_date->add_duration($days_duration); |
211 |
$base_date->add_duration($days_duration); |
| 213 |
|
212 |
|
| 214 |
if ( $self->{days_mode} eq 'Datedue' ) { |
213 |
if ( $self->{days_mode} eq 'Datedue' || |
| 215 |
# Datedue, then use the calendar to push |
214 |
$self->{days_mode} eq 'Dayweek') { |
|
|
215 |
# Datedue or Dayweek, then use the calendar to push |
| 216 |
# the date to the next open day if holiday |
216 |
# the date to the next open day if holiday |
| 217 |
if ( $self->is_holiday($base_date) ) { |
217 |
if ( $self->is_holiday($base_date) ) { |
| 218 |
|
218 |
my $dow = $base_date->day_of_week; |
|
|
219 |
my $days = $days_duration->in_units('days'); |
| 220 |
my $push_amt = ( |
| 221 |
# We're using Dayweek useDaysMode option |
| 222 |
$self->{days_mode} eq 'Dayweek' && |
| 223 |
# It's period based on weeks |
| 224 |
$days % 7 == 0 && |
| 225 |
# It's not a permanently closed day |
| 226 |
!$self->{weekly_closed_days}->[$dow] == 1 |
| 227 |
) ? 7 : 1; |
| 219 |
if ( $days_duration->is_negative() ) { |
228 |
if ( $days_duration->is_negative() ) { |
| 220 |
$base_date = $self->prev_open_day($base_date); |
229 |
$base_date = $self->prev_open_days($base_date, $push_amt); |
| 221 |
} else { |
230 |
} else { |
| 222 |
$base_date = $self->next_open_day($base_date); |
231 |
$base_date = $self->next_open_days($base_date, $push_amt); |
| 223 |
} |
232 |
} |
| 224 |
} |
233 |
} |
| 225 |
} |
234 |
} |
|
Lines 275-285
sub next_open_days {
Link Here
|
| 275 |
my $base_date = $dt->clone(); |
284 |
my $base_date = $dt->clone(); |
| 276 |
|
285 |
|
| 277 |
$base_date->add(days => $to_add); |
286 |
$base_date->add(days => $to_add); |
| 278 |
|
|
|
| 279 |
while ($self->is_holiday($base_date)) { |
287 |
while ($self->is_holiday($base_date)) { |
| 280 |
$base_date->add(days => $to_add); |
288 |
$base_date->add(days => $to_add); |
| 281 |
} |
289 |
} |
| 282 |
|
|
|
| 283 |
return $base_date; |
290 |
return $base_date; |
| 284 |
} |
291 |
} |
| 285 |
|
292 |
|
| 286 |
- |
|
|