commit b0ca1234fd627802dc09bb16b62c3a233dd61996
parent 8dc1039990c2352b7fb70fa054eeb5a60e63f3a1
Author: qorg11 <qorg@vxempire.xyz>
Date: Sun, 15 Nov 2020 15:30:59 +0100
Added a probably non posix compliant date(1) but it works :DDD
Diffstat:
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/date.c b/src/date.c
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <string.h>
+int
+main(int argc,char *argv[])
+{
+ int c;
+ int u = 0;
+ char buffer[256];
+ time_t now;
+ now = time(NULL);
+ char FORMAT[256] = "%F %H:%M:%S";
+ struct tm *timeinfo;
+
+ while((c = getopt(argc,argv,"u")) != -1)
+ {
+ switch(c)
+ {
+ case 'u': u = 1; break;
+ }
+ }
+
+ timeinfo = localtime(&now);
+
+ if(u)
+ {
+ timeinfo = gmtime(&now);
+ }
+
+ if(argc > optind && argv[optind][0] == '+')
+ {
+ argv[optind] = strtok(argv[optind],"+");
+ strcpy(FORMAT,argv[optind]);
+ }
+
+ strftime(buffer,256,FORMAT,timeinfo);
+ puts(buffer);
+ return 0;
+}
diff --git a/src/ls.c b/src/ls.c
@@ -22,8 +22,6 @@ main(int argc, char *argv[])
}
}
-
-
DIR *dir = opendir(".");
struct dirent *ent;