Skip to content

Commit 54f64da

Browse files
Merge branch 'DFHack:master' into realSquidCoder-patch-1
2 parents 4cacf13 + bbba0a3 commit 54f64da

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
args: ['--fix=lf']
2121
- id: trailing-whitespace
2222
- repo: https://github.com/python-jsonschema/check-jsonschema
23-
rev: 0.31.2
23+
rev: 0.32.1
2424
hooks:
2525
- id: check-github-workflows
2626
- repo: https://github.com/Lucas-C/pre-commit-hooks

changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Template for new versions:
3131
## New Features
3232

3333
## Fixes
34+
- `list-agreements`: fix date math when determining petition age
35+
- `gui/petitions`: fix date math when determining petition age
3436

3537
## Misc Improvements
3638
- `fix/loyaltycascade`: now also breaks up brawls and other intra-fort conflicts that *look* like loyalty cascades

list-agreements.lua

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ function get_petition_age(agr)
3535
local agr_year = agr.details[0].year
3636
local cur_year_tick = df.global.cur_year_tick
3737
local cur_year = df.global.cur_year
38-
local del_year, del_year_tick
39-
--delta, check to prevent off by 1 error, not validated
40-
if cur_year_tick > agr_year_tick then
41-
del_year = cur_year - agr_year
42-
del_year_tick = cur_year_tick - agr_year_tick
43-
else
44-
del_year = cur_year - agr_year - 1
45-
del_year_tick = agr_year_tick - cur_year_tick
38+
local del_year = cur_year - agr_year
39+
local del_year_tick = cur_year_tick - agr_year_tick
40+
if del_year_tick < 0 then
41+
del_year = del_year - 1
42+
del_year_tick = del_year_tick + 403200
4643
end
47-
local julian_day = math.floor(del_year_tick / 1200) + 1
44+
-- Round up to the nearest day, since we don't do fractions
45+
local julian_day = math.ceil(del_year_tick / 1200)
4846
local del_month = math.floor(julian_day / 28)
4947
local del_day = julian_day % 28
5048
return {del_year,del_month,del_day}

0 commit comments

Comments
 (0)