[libc-commits] [libc] [libc] implement localtime (PR #110363)

Зишан Мирза via libc-commits libc-commits at lists.llvm.org
Sun Oct 6 13:32:56 PDT 2024


================
@@ -129,6 +130,22 @@ int64_t update_from_seconds(int64_t total_seconds, struct tm *tm) {
   if (years > INT_MAX || years < INT_MIN)
     return time_utils::out_of_range();
 
+  char timezone[128];
+
+  FILE *fp;
+  fp = fopen("/etc/timezone", "rb");
+  if (fp == NULL) {
+    // TODO: implement getting timezone from `TZ` environment variable and
+    // storing the value in `timezone`
+  } else if (fgets(timezone, sizeof(timezone), fp) == NULL)
+    return time_utils::out_of_range();
----------------
zimirza wrote:

Sure, I have now refactored the file read.

https://github.com/llvm/llvm-project/pull/110363


More information about the libc-commits mailing list