Skip to content

Commit 5466d1e

Browse files
committed
Fix year issue
1 parent de9726a commit 5466d1e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/rest-nvim/utils.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ function utils.read_file(path)
8383
return content
8484
end
8585

86+
local function fix_year(year)
87+
if year < 100 then
88+
return year + 2000
89+
end
90+
91+
return year
92+
end
93+
8694
function utils.parse_http_time(time_str)
8795
local pattern = "(%a+), (%d+)[%s-](%a+)[%s-](%d+) (%d+):(%d+):(%d+) GMT"
8896
local _, day, month_name, year, hour, min, sec = time_str:match(pattern)
@@ -92,7 +100,7 @@ function utils.parse_http_time(time_str)
92100
Jul = 7, Aug = 8, Sep = 9, Oct = 10, Nov = 11, Dec = 12,
93101
}
94102
local time_table = {
95-
year = tonumber(year),
103+
year = fix_year(tonumber(year)),
96104
month = months[month_name],
97105
day = tonumber(day),
98106
hour = tonumber(hour),

0 commit comments

Comments
 (0)