Skip to content

Commit fdc77eb

Browse files
Use agenda item real date and time when applying sort. Closes #337.
1 parent da9a0cf commit fdc77eb

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

lua/orgmode/agenda/agenda_item.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ end
1212
---@class AgendaItem
1313
---@field date Date
1414
---@field headline_date Date
15+
---@field real_date Date
1516
---@field headline Section
1617
---@field is_valid boolean
1718
---@field is_today boolean
@@ -29,6 +30,7 @@ local AgendaItem = {}
2930
function AgendaItem:new(headline_date, headline, date, index)
3031
local opts = {}
3132
opts.headline_date = headline_date
33+
opts.real_date = headline_date:apply_repeater_until(date)
3234
opts.headline = headline
3335
opts.date = date
3436
opts.index = index or 1

lua/orgmode/agenda/views/agenda.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ local function sort_by_date_or_priority_or_category(a, b)
1111
if a.headline:get_priority_sort_value() ~= b.headline:get_priority_sort_value() then
1212
return a.headline:get_priority_sort_value() > b.headline:get_priority_sort_value()
1313
end
14-
if not a.headline_date:is_same(b.headline_date, 'day') then
15-
return a.headline_date:is_before(b.headline_date)
14+
if not a.real_date:is_same(b.real_date, 'day') then
15+
return a.real_date:is_before(b.real_date)
1616
end
1717
return a.index < b.index
1818
end
@@ -22,26 +22,26 @@ end
2222
local function sort_agenda_items(agenda_items)
2323
table.sort(agenda_items, function(a, b)
2424
if a.is_same_day and b.is_same_day then
25-
if not a.headline_date.date_only and b.headline_date.date_only then
25+
if not a.real_date.date_only and b.real_date.date_only then
2626
return true
2727
end
28-
if not b.headline_date.date_only and a.headline_date.date_only then
28+
if not b.real_date.date_only and a.real_date.date_only then
2929
return false
3030
end
31-
if not a.headline_date.date_only and not b.headline_date.date_only then
32-
return a.headline_date:is_before(b.headline_date)
31+
if not a.real_date.date_only and not b.real_date.date_only then
32+
return a.real_date:is_before(b.real_date)
3333
end
3434
return sort_by_date_or_priority_or_category(a, b)
3535
end
3636

3737
if a.is_same_day and not b.is_same_day then
38-
if not a.headline_date.date_only or (b.headline_date:is_none() and not a.headline_date:is_none()) then
38+
if not a.real_date.date_only or (b.real_date:is_none() and not a.real_date:is_none()) then
3939
return true
4040
end
4141
end
4242

4343
if not a.is_same_day and b.is_same_day then
44-
if not b.headline_date.date_only or (a.headline_date:is_none() and not b.headline_date:is_none()) then
44+
if not b.real_date.date_only or (a.real_date:is_none() and not b.real_date:is_none()) then
4545
return false
4646
end
4747
end

0 commit comments

Comments
 (0)