Skip to content

Commit ad5d652

Browse files
fix(datetree): Use current date and time as default value for datetree
This fixes the issue where current time is used as template value
1 parent f4dde88 commit ad5d652

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lua/orgmode/capture/template/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function Template:get_datetree_opts()
220220
---@diagnostic disable-next-line: param-type-mismatch
221221
local datetree = vim.deepcopy(self.datetree)
222222
datetree = (type(datetree) == 'table' and datetree) or {}
223-
datetree.date = datetree.date or Date.today()
223+
datetree.date = datetree.date or Date.now()
224224
datetree.tree_type = datetree.tree_type or 'day'
225225
return datetree
226226
end

tests/plenary/capture/templates_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ describe('Capture template', function()
3939
vim.fn.setreg('+', clip_backup)
4040
end)
4141

42-
it('gets current date for datetree enabled with true', function()
42+
it('gets current date and time for datetree enabled with true', function()
4343
local template = Template:new({
4444
template = '* %?',
4545
datetree = true,
4646
})
4747

48-
assert.are.same(Date.today():to_string(), template:get_datetree_opts().date:to_string())
48+
assert.are.same(Date.now():to_string(), template:get_datetree_opts().date:to_string())
4949
end)
5050

5151
it('gets a proper date for datetree enabled as time prompt', function()

0 commit comments

Comments
 (0)