Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c68a87c

Browse files
fix(calendar): default to current time when switching to time input
Fixes #883
1 parent 5a24ab8 commit c68a87c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lua/orgmode/objects/calendar.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,9 @@ end
632632

633633
function Calendar:set_time()
634634
self.date = self:get_selected_date()
635-
self.date = self.date:set({ date_only = false })
635+
if self.date.date_only then
636+
self.date = self.date:set({ date_only = false }):set_current_time()
637+
end
636638
--self:rerender_time()
637639
self:set_sel_hour()
638640
self:render() -- because we want to highlight the currently selected date, we have to render everything

lua/orgmode/objects/date.lua

+8
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,14 @@ function OrgDate:set_todays_date()
983983
})
984984
end
985985

986+
function OrgDate:set_current_time()
987+
local time = os_date(os.time())
988+
return self:set({
989+
hour = tonumber(time.hour) or 0,
990+
min = tonumber(time.min) or 0,
991+
})
992+
end
993+
986994
---@return OrgDate
987995
function OrgDate:apply_repeater()
988996
local repeater = self:get_repeater()

0 commit comments

Comments
 (0)