ropg / ezTime

ezTime — pronounced "Easy Time" — is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.
MIT License
343 stars 93 forks source link

day(t) seems to return incorrect value #162

Open nilton61 opened 2 years ago

nilton61 commented 2 years ago

I have the following function to calculate the civil dawn time:

#include <ezTime.h>
#include <ESP8266WiFi.h>
#include <SolarCalculator.h>

calculate dawn(t){
  Serial.println("calculating dawn");
  Serial.println("time passed to calculate dawn: " + dateTime(t));
  double tr, dawn, dusk;
  calcCivilDawnDusk(t, latitude, longitude, tr, dawn, dusk);
  Serial.println("t after calculation: " + dateTime(t));
  dawn += 1.0;//needs to be offset
  Serial.print("day t: ");
  Serial.println(day(t));//this prints the wrong value, 21(today) instead of 22 on my test run
  ....
}

I got some suspicious result, that's why i inserted the print statements and i got the following:

calculating dawn
time passed to calculate dawn: Tuesday, 22-Nov-2022 00:00:01 CET
t after calculation: Tuesday, 22-Nov-2022 00:00:01 CET
day t: 21

It seems that day(t) ignores the t parameter and uses the current time. If this is my error that i missed somewhere i apologize and I'll be grateful if you point it out to me