@@ -66,72 +66,6 @@ function M.indent_code_block(text)
6666 return vim .trim (table.concat (content , ' \n ' ))
6767end
6868
69- -- Get timezone offset in seconds for various timezone formats
70- function M .get_timezone_offset (timezone )
71- -- Handle numeric timezone formats (+HHMM, -HHMM)
72- if timezone :match (' ^[%+%-]%d%d:?%d%d$' ) then
73- local sign = timezone :sub (1 , 1 ) == ' +' and 1 or - 1
74- local hours = tonumber (timezone :match (' ^[%+%-](%d%d)' ))
75- local mins = tonumber (timezone :match (' ^[%+%-]%d%d:?(%d%d)$' ) or ' 00' )
76- return sign * (hours * 3600 + mins * 60 )
77- end
78-
79- -- Map of common timezone abbreviations to their offset in seconds from UTC
80- local timezone_map = {
81- -- Zero offset timezones
82- [' UTC' ] = 0 ,
83- [' GMT' ] = 0 ,
84-
85- -- North America
86- [' EST' ] = - 5 * 3600 ,
87- [' EDT' ] = - 4 * 3600 ,
88- [' CST' ] = - 6 * 3600 ,
89- [' CDT' ] = - 5 * 3600 ,
90- [' MST' ] = - 7 * 3600 ,
91- [' MDT' ] = - 6 * 3600 ,
92- [' PST' ] = - 8 * 3600 ,
93- [' PDT' ] = - 7 * 3600 ,
94- [' AKST' ] = - 9 * 3600 ,
95- [' AKDT' ] = - 8 * 3600 ,
96- [' HST' ] = - 10 * 3600 ,
97-
98- -- Europe
99- [' WET' ] = 0 ,
100- [' WEST' ] = 1 * 3600 ,
101- [' CET' ] = 1 * 3600 ,
102- [' CEST' ] = 2 * 3600 ,
103- [' EET' ] = 2 * 3600 ,
104- [' EEST' ] = 3 * 3600 ,
105- [' MSK' ] = 3 * 3600 ,
106- [' BST' ] = 1 * 3600 ,
107-
108- -- Asia & Middle East
109- [' IST' ] = 5.5 * 3600 ,
110- [' PKT' ] = 5 * 3600 ,
111- [' HKT' ] = 8 * 3600 ,
112- [' PHT' ] = 8 * 3600 ,
113- [' JST' ] = 9 * 3600 ,
114- [' KST' ] = 9 * 3600 ,
115-
116- -- Australia & Pacific
117- [' AWST' ] = 8 * 3600 ,
118- [' ACST' ] = 9.5 * 3600 ,
119- [' AEST' ] = 10 * 3600 ,
120- [' AEDT' ] = 11 * 3600 ,
121- [' NZST' ] = 12 * 3600 ,
122- [' NZDT' ] = 13 * 3600 ,
123- }
124-
125- -- Handle special cases for ambiguous abbreviations
126- if timezone == ' CST' and not timezone_map [timezone ] then
127- -- In most contexts, CST refers to Central Standard Time (US)
128- return - 6 * 3600
129- end
130-
131- -- Return the timezone offset or default to UTC (0)
132- return timezone_map [timezone ] or 0
133- end
134-
13569-- Reset all ANSI styling
13670function M .ansi_reset ()
13771 return ' \27 [0m'
@@ -199,17 +133,14 @@ function M.format_time(timestamp)
199133 timestamp = math.floor (timestamp / 1000 )
200134 end
201135
202- local now = os.time ()
203- local today_start = os.time (os.date (' *t' , now ))
204- - os.date (' *t' , now ).hour * 3600
205- - os.date (' *t' , now ).min * 60
206- - os.date (' *t' , now ).sec
136+ local local_t = os.date (' *t' ) --[[ @as std.osdateparam]]
137+ local today_start = os.time ({ year = local_t .year , month = local_t .month , day = local_t .day })
207138
208139 if timestamp >= today_start then
209- return os.date (' %I:%M %p' , timestamp )
210- else
211- return os.date (' %d %b %Y %I:%M %p' , timestamp )
140+ return os.date (' %I:%M %p' , timestamp ) --[[ @as string]]
212141 end
142+
143+ return os.date (' %d %b %Y %I:%M %p' , timestamp ) --[[ @as string]]
213144end
214145
215146function M .index_of (tbl , value )
@@ -410,6 +341,7 @@ function M.check_prompt_allowed(guard_callback, mentioned_files)
410341 return false , ' prompt_guard must return a boolean'
411342 end
412343
344+ --- @cast result boolean
413345 return result , nil
414346end
415347
0 commit comments