Skip to content

Commit 31fafad

Browse files
Date Searching (#487)
1 parent 24aac55 commit 31fafad

File tree

5 files changed

+652
-96
lines changed

5 files changed

+652
-96
lines changed

lua/orgmode/objects/date.lua

+29-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,28 @@ local time_format = '%H:%M'
2525
---@field related_date_range Date
2626
---@field dayname string
2727
---@field adjustments string[]
28-
local Date = {}
28+
local Date = {
29+
---@type fun(this: Date, other: Date): boolean
30+
__eq = function(this, other)
31+
return this.timestamp == other.timestamp
32+
end,
33+
---@type fun(this: Date, other: Date): boolean
34+
__lt = function(this, other)
35+
return this.timestamp < other.timestamp
36+
end,
37+
---@type fun(this: Date, other: Date): boolean
38+
__le = function(this, other)
39+
return this.timestamp <= other.timestamp
40+
end,
41+
---@type fun(this: Date, other: Date): boolean
42+
__gt = function(this, other)
43+
return this.timestamp > other.timestamp
44+
end,
45+
---@type fun(this: Date, other: Date): boolean
46+
__ge = function(this, other)
47+
return this.timestamp >= other.timestamp
48+
end,
49+
}
2950

3051
---@param source table
3152
---@param target? table
@@ -166,6 +187,12 @@ local function today(data)
166187
return Date:new(opts)
167188
end
168189

190+
---@return Date
191+
local function tomorrow()
192+
local today_date = today()
193+
return today_date:adjust('+1d')
194+
end
195+
169196
---@param data? table
170197
---@return Date
171198
local function now(data)
@@ -909,6 +936,7 @@ return {
909936
from_string = from_string,
910937
now = now,
911938
today = today,
939+
tomorrow = tomorrow,
912940
parse_all_from_line = parse_all_from_line,
913941
is_valid_date = is_valid_date,
914942
is_date_instance = is_date_instance,

lua/orgmode/parser/file.lua

+8
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,17 @@ function File:apply_search(search, todo_only)
205205
if item:is_archived() or (todo_only and not item:is_todo()) then
206206
return false
207207
end
208+
209+
local deadline = item:get_deadline_date()
210+
local scheduled = item:get_scheduled_date()
211+
local closed = item:get_closed_date()
212+
208213
return search:check({
209214
props = vim.tbl_extend('keep', {}, item.properties.items, {
210215
category = item.category,
216+
deadline = deadline and deadline:to_wrapped_string(true),
217+
scheduled = scheduled and scheduled:to_wrapped_string(true),
218+
closed = closed and closed:to_wrapped_string(false),
211219
}),
212220
tags = item.tags,
213221
todo = item.todo_keyword.value,

0 commit comments

Comments
 (0)