#ifndef __USER_TIME_H__
#define __USER_TIME_H__

#include "SPIFFS.h"
#include <stdbool.h>


void user_time_init();
void user_time_handler();

#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>


void setRtcTime(unsigned int year, unsigned int month, unsigned int day, 
                unsigned int hour, unsigned int minute, unsigned int second);

void getRtcTime(Machine_info_t *info);


bool is_sync_time(Machine_info_t *info);

long long calculate_minutes_difference(int year1, int month1, int day1, int hour1, int minute1, int second1,
                                       int year2, int month2, int day2, int hour2, int minute2, int second2);


// void timestampToStr(const char* timestamp_str, char* output_buffer, int size, int timezone_offset);
// char* extractTimestamp(const char* input_str);


#if 0
void timestamp_to_local_time(const char *timestamp, int *year, int *month, int *day, int *hour, int *minute, int *second);
#else
void timestamp_to_local_time(const char *timestamp, int offset, int *year, uint8_t *month, uint8_t *day, uint8_t *hour, uint8_t *minute, uint8_t *second);
#endif
#endif