misc: change |age_in_working_days so it can return negative values (#71759)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
f08120f8e2
commit
3c411ce651
|
@ -1162,9 +1162,9 @@ def test_age_in_working_days_settings(settings, pub, freezer):
|
|||
assert t.render({'value': '2020-07-12'}) == '2'
|
||||
settings.WORKING_DAY_CALENDAR = 'workalendar.europe.France'
|
||||
t = Template('{{ value|age_in_working_days }}')
|
||||
assert t.render({'value': '2020-07-12'}) == '7'
|
||||
assert t.render({'value': '2020-07-12'}) == '-7'
|
||||
t = Template('{{ value|age_in_working_days_with_saturday }}')
|
||||
assert t.render({'value': '2020-07-12'}) == '9'
|
||||
assert t.render({'value': '2020-07-12'}) == '-9'
|
||||
|
||||
pub.site_options.set('options', 'working_day_calendar', 'foobar')
|
||||
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
|
||||
|
|
|
@ -482,7 +482,10 @@ def age_in_working_days(value, arg=None, saturday_is_a_working_day=False):
|
|||
if not cal:
|
||||
return ''
|
||||
|
||||
return cal.get_working_days_delta(value, arg)
|
||||
delta = cal.get_working_days_delta(value, arg)
|
||||
if arg.timetuple() < value.timetuple():
|
||||
delta = -delta
|
||||
return delta
|
||||
|
||||
|
||||
@register.filter(expects_localtime=True)
|
||||
|
|
Loading…
Reference in New Issue