From 5466d1e447fc4b038ef511a7a2c4c7cbb13da01a Mon Sep 17 00:00:00 2001 From: Nuruddin Ashr Date: Tue, 7 Oct 2025 17:22:04 +0700 Subject: [PATCH] Fix year issue --- lua/rest-nvim/utils.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/rest-nvim/utils.lua b/lua/rest-nvim/utils.lua index e9cf85df..4f4ee933 100644 --- a/lua/rest-nvim/utils.lua +++ b/lua/rest-nvim/utils.lua @@ -83,6 +83,14 @@ function utils.read_file(path) return content end +local function fix_year(year) + if year < 100 then + return year + 2000 + end + + return year +end + function utils.parse_http_time(time_str) local pattern = "(%a+), (%d+)[%s-](%a+)[%s-](%d+) (%d+):(%d+):(%d+) GMT" local _, day, month_name, year, hour, min, sec = time_str:match(pattern) @@ -92,7 +100,7 @@ function utils.parse_http_time(time_str) Jul = 7, Aug = 8, Sep = 9, Oct = 10, Nov = 11, Dec = 12, } local time_table = { - year = tonumber(year), + year = fix_year(tonumber(year)), month = months[month_name], day = tonumber(day), hour = tonumber(hour),