aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqorg11 <qorg@vxempire.xyz>2020-11-15 15:30:59 +0100
committerqorg11 <qorg@vxempire.xyz>2020-11-15 15:30:59 +0100
commitb0ca1234fd627802dc09bb16b62c3a233dd61996 (patch)
tree8fdfeb258990b4a727dbc7d9a2552fa32d037beb
parent8dc1039990c2352b7fb70fa054eeb5a60e63f3a1 (diff)
downloadk9core-b0ca1234fd627802dc09bb16b62c3a233dd61996.tar.gz
k9core-b0ca1234fd627802dc09bb16b62c3a233dd61996.zip
Added a probably non posix compliant date(1) but it works :DDD
-rw-r--r--src/date.c41
-rw-r--r--src/ls.c2
2 files changed, 41 insertions, 2 deletions
diff --git a/src/date.c b/src/date.c
new file mode 100644
index 0000000..78b41ea
--- /dev/null
+++ 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
index 63c4ede..41a6262 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -22,8 +22,6 @@ main(int argc, char *argv[])
}
}
-
-
DIR *dir = opendir(".");
struct dirent *ent;