aboutsummaryrefslogtreecommitdiff
path: root/src/common/protocol.c
blob: 9be3bcfbca07c6c5e81b3014ac7c9c03f381f577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);
}