shithub: femtolisp

Download patch

ref: 860071f62ae03ff157eb2ba2dcbd45f21cb5ec36
parent: 6d724e4899ea1e4e7164e98dfead7e3815372297
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Mon Nov 30 09:06:23 EST 2020

fix time.string

--- a/flmain.c
+++ b/flmain.c
@@ -31,6 +31,7 @@
 
 #ifdef __plan9__
     setfcr(FPPDBL|FPRNR|FPOVFL);
+    tmfmtinstall();
 #endif
 
     fl_init(512*1024);
--- a/llt/timefuncs.c
+++ b/llt/timefuncs.c
@@ -91,8 +91,8 @@
 void timestring(double seconds, char *buffer, size_t len)
 {
 #ifdef __plan9__
-    buffer[0] = 0; // FIXME
-    USED(seconds, buffer, len);
+    Tm tm;
+    snprint(buffer, len, "%τ", tmfmt(tmtime(&tm, seconds, tzload("local")), nil));
 #elif defined(LINUX) || defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
     time_t tme = (time_t)seconds;
 
@@ -166,26 +166,5 @@
     timeout.tv_sec = ms/1000;
     timeout.tv_usec = (ms % 1000) * 1000;
     select(0, NULL, NULL, NULL, &timeout);
-#endif
-}
-
-void timeparts(int32_t *buf, double t)
-{
-#ifdef __plan9__
-    // FIXME wtf
-    USED(buf, t);
-#elif !defined(WIN32)
-    time_t tme = (time_t)t;
-    struct tm tm;
-    localtime_r(&tme, &tm);
-    tm.tm_year += 1900;
-    memcpy(buf, (char*)&tm, sizeof(struct tm));
-#else
-    time_t tme = (time_t)t;
-    struct tm *tm;
-
-    tm = localtime(&tme);
-    tm->tm_year += 1900;
-    memcpy(buf, (char*)tm, sizeof(struct tm));
 #endif
 }
--- a/llt/timefuncs.h
+++ b/llt/timefuncs.h
@@ -6,6 +6,5 @@
 void timestring(double seconds, char *buffer, size_t len);
 double parsetime(const char *str);
 void sleep_ms(int ms);
-void timeparts(int32_t *buf, double t);
 
 #endif