diff --git a/modules/llm-cache/storage/file_storage.cc b/modules/llm-cache/storage/file_storage.cc index 3f5cdc0c8..44bd43ad1 100644 --- a/modules/llm-cache/storage/file_storage.cc +++ b/modules/llm-cache/storage/file_storage.cc @@ -663,8 +663,8 @@ void FileStorage::PrintFileAccessTime(std::string path) { std::string FileStorage::GetTimestamp( std::chrono::duration time) { - std::chrono::time_point timestamp = - std::chrono::time_point(time); + auto duration_since_epoch = std::chrono::duration_cast(time); + std::chrono::time_point timestamp = std::chrono::system_clock::time_point(duration_since_epoch); time_t t = std::chrono::system_clock::to_time_t(timestamp); std::tm tm; diff --git a/modules/llm-cache/storage/local_file_storage.cc b/modules/llm-cache/storage/local_file_storage.cc index 2a74ba5a2..d054e0998 100644 --- a/modules/llm-cache/storage/local_file_storage.cc +++ b/modules/llm-cache/storage/local_file_storage.cc @@ -192,8 +192,13 @@ Status LocalFileStorage::GetFileAccessTime( return Status::IOError("Failed to get file access time: " + formatIOError(path)); } - accessTime = std::chrono::duration( - statbuf.st_atim.tv_sec * SECOND_TO_NANOSECOND + statbuf.st_atim.tv_nsec); + #ifdef __APPLE__ + accessTime = std::chrono::duration( + statbuf.st_atimespec.tv_sec * SECOND_TO_NANOSECOND + statbuf.st_atimespec.tv_nsec); + #else + accessTime = std::chrono::duration( + statbuf.st_atim.tv_sec * SECOND_TO_NANOSECOND + statbuf.st_atim.tv_nsec); + #endif return Status::OK(); }