Hi, I need to use ezTime lib instead of TimeLib. I modified the sunMoon.h header:
`#ifndef _SUN_MOON_H
#define _SUN_MOON_H
#include <ezTime.h>
#include <math.h>
class sunMoon {
`
and supposed that it will work. But I got some strange compilation error which seems not to be related to this change, but somehow is:
In file included from D:\arduino\projects\libraries\ezTime\src/ezTime.h:41:0,
from D:\arduino\projects\libraries\sunMoon-master\src\sunMoon.h:4,
from D:\arduino\projects\libraries\sunMoon-master\src\sunMoon.cpp:1:
C:\Users\Dell\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4/tools/sdk/libc/xtensa-lx106-elf/include/sys/types.h:122:18: error: conflicting declaration 'typedef long int time_t'
typedef TIME_T time_t;
^
In file included from D:\arduino\projects\libraries\sunMoon-master\src\sunMoon.h:4:0,
from D:\arduino\projects\libraries\sunMoon-master\src\sunMoon.cpp:1:
D:\arduino\projects\libraries\ezTime\src/ezTime.h:36:24: error: 'time_t' has a previous declaration as 'typedef long unsigned int time_t'
typedef unsigned long time_t;
^
It has something to do with the time_t declaration, but I don't do anything with it.
The full test code is here:
`#include <Arduino.h>
//#include <TimeLib.h>
#include <ezTime.h>
#include <sunMoon.h>
#define OUR_latitude 49.4
#define OUR_longtitude 18.2
#define OUR_timezone 120 // localtime with UTC difference in minutes
sunMoon sm;
void printDate(time_t date) {
char buff[20];
sprintf(buff, "%2d-%02d-%4d %02d:%02d:%02d", day(date), month(date), year(date), hour(date), minute(date), second(date));
Serial.print(buff);
}
void setup() {
tmElements_t tm; // specific time
tm.Second = 0;
tm.Minute = 0;
tm.Hour = 12;
tm.Day = 26;
tm.Month = 4;
tm.Year = 2021 - 1970;
time_t s_date = makeTime(tm);
Serial.begin(115200);
Serial.println();
sm.init(OUR_timezone, OUR_latitude, OUR_longtitude);
uint32_t jDay = sm.julianDay(s_date); // Optional call
byte mDay = sm.moonDay(s_date);
time_t sRise = sm.sunRise(s_date);
time_t sSet = sm.sunSet(s_date);
Serial.print("Today is "); Serial.print(jDay); Serial.println(" Julian day");
Serial.print("Moon age is "); Serial.print(mDay); Serial.println("day(s)");
Serial.print("Today sunrise and sunset: ");
printDate(sRise); Serial.print("; ");
printDate(sSet); Serial.println("");
}
void loop() {
// put your main code here, to run repeatedly:
}
`
Please be so kind and help me to find the root cause.