aboutsummaryrefslogtreecommitdiff
path: root/src/common/protocol.c
diff options
context:
space:
mode:
authorPreston Pan <ret2pop@gmail.com>2025-01-09 16:32:55 -0800
committerPreston Pan <ret2pop@gmail.com>2025-01-09 16:32:55 -0800
commitef9ab1fd141f4057d41f2d6ed8ab8d67c44894d5 (patch)
treee4005b7a641303b021eb54c2aae5676b5f92a72d /src/common/protocol.c
parent1fd608288ee47c2c560817f12f14b21069fed2f6 (diff)
save stateHEADmain
Diffstat (limited to 'src/common/protocol.c')
-rw-r--r--src/common/protocol.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common/protocol.c b/src/common/protocol.c
new file mode 100644
index 0000000..9be3bcf
--- /dev/null
+++ b/src/common/protocol.c
@@ -0,0 +1,20 @@
+#include "../include/protocol.h"
+#include "../include/better_string.h"
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <time.h>
+
+string_t *date_str() {
+ char dateStr[11];
+ time_t t = time(NULL);
+ struct tm *tm_info = localtime(&t);
+
+ strftime(dateStr, sizeof(dateStr), "%d-%m-%Y", tm_info);
+ return init_string(dateStr);
+}
+
+bool same_day(struct tm *date1, struct tm *date2) {
+ return (date1->tm_year == date2->tm_year && date1->tm_mon == date2->tm_mon &&
+ date1->tm_mday == date2->tm_mday);
+}