From 8c769d00ce53613f55d710ace3b7edc0173d3d0c Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 11 Mar 2026 13:52:44 +0300 Subject: [PATCH] os: year-2038 problem (fixes #26664) --- vlib/os/os_nix.c.v | 2 +- vlib/os/os_structs_stat_default.c.v | 8 ++++---- vlib/os/os_structs_utsname_default.c.v | 4 ++-- vlib/os/os_test.c.v | 7 +++---- vlib/os/os_windows.c.v | 6 +++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/vlib/os/os_nix.c.v b/vlib/os/os_nix.c.v index a3d89bdbb..526b43d11 100644 --- a/vlib/os/os_nix.c.v +++ b/vlib/os/os_nix.c.v @@ -201,7 +201,7 @@ fn native_glob_pattern(pattern string, mut matches []string) ! { // utime changes the access and modification times of the inode specified by path. // It returns POSIX error message, if it can not do so. -pub fn utime(path string, actime int, modtime int) ! { +pub fn utime(path string, actime i64, modtime i64) ! { u := C.utimbuf{actime, modtime} if C.utime(&char(path.str), &u) != 0 { return error_with_code(posix_get_error_msg(C.errno), C.errno) diff --git a/vlib/os/os_structs_stat_default.c.v b/vlib/os/os_structs_stat_default.c.v index 45aca0076..d812b6d47 100644 --- a/vlib/os/os_structs_stat_default.c.v +++ b/vlib/os/os_structs_stat_default.c.v @@ -11,13 +11,13 @@ pub struct C.stat { st_gid u32 st_rdev u64 st_size u64 - st_atime int - st_mtime int - st_ctime int + st_atime i64 + st_mtime i64 + st_ctime i64 } pub struct C.__stat64 { st_size u64 st_mode u32 - st_mtime int + st_mtime i64 } diff --git a/vlib/os/os_structs_utsname_default.c.v b/vlib/os/os_structs_utsname_default.c.v index 5782afffd..f10eeafec 100644 --- a/vlib/os/os_structs_utsname_default.c.v +++ b/vlib/os/os_structs_utsname_default.c.v @@ -10,6 +10,6 @@ mut: } pub struct C.utimbuf { - actime int - modtime int + actime i64 + modtime i64 } diff --git a/vlib/os/os_test.c.v b/vlib/os/os_test.c.v index b9c3caa02..02c3b6e30 100644 --- a/vlib/os/os_test.c.v +++ b/vlib/os/os_test.c.v @@ -1,5 +1,4 @@ import os -import time // tfolder will contain all the temporary files/subfolders made by // the different tests. It would be removed in testsuite_end(), so @@ -1001,9 +1000,9 @@ fn test_utime() { os.rm(filename) or { panic(err) } } f.write_string(hello) or { panic(err) } - atime := time.now().add_days(2).unix() - mtime := time.now().add_days(4).unix() - os.utime(filename, int(atime), int(mtime)) or { panic(err) } + atime := i64(2_147_483_648) + mtime := i64(2_306_102_495) + os.utime(filename, atime, mtime) or { panic(err) } assert os.file_last_mod_unix(filename) == mtime } diff --git a/vlib/os/os_windows.c.v b/vlib/os/os_windows.c.v index 4bf1722c4..b8caa679d 100644 --- a/vlib/os/os_windows.c.v +++ b/vlib/os/os_windows.c.v @@ -114,8 +114,8 @@ mut: } pub struct C._utimbuf { - actime int - modtime int + actime i64 + modtime i64 } fn C._utime(&char, voidptr) i32 @@ -176,7 +176,7 @@ fn native_glob_pattern(pattern string, mut matches []string) ! { } } -pub fn utime(path string, actime int, modtime int) ! { +pub fn utime(path string, actime i64, modtime i64) ! { mut u := C._utimbuf{actime, modtime} if C._utime(&char(path.str), voidptr(&u)) != 0 { return error_with_code(posix_get_error_msg(C.errno), C.errno) -- 2.39.5