Page 2 of 2

Re: What day was yesterday?

Posted: Fri Jul 30, 2021 5:24 pm
by Fernando Perez
I understand what you are saying and I think you are right. Thanks Ulli.
If it doesn't bother you and Eric, can you confirm that it returns the instruction from my initial query?

Code: [Local Link Removed for Guests]

day$ = unixDate$((dateUnix(date$) - 86400))
wlog day$

Re: What day was yesterday?

Posted: Fri Jul 30, 2021 11:17 pm
by ulli
Hi Fernando,

I currently don't have equipment for testing at hand, but your solution looks correct.

Cheers

Ulli

Re: What day was yesterday?

Posted: Fri Jul 30, 2021 11:34 pm
by Fernando Perez
In theory, this should be a correct solution for my purpose of subtracting a day from a date.
But my problem is that in practice (and I have tested it on ESP8266 and ESP32, with Annex 1.43.3), it returns the date minus two days, not just one.
However, it works for Cicciocb.
That's why I asked more people, from different countries, to run the code and tell me the result.
I try to find out what my mistake is

Re: What day was yesterday?

Posted: Sat Jul 31, 2021 8:48 am
by ulli
Hi Fernando,

there's probably something wrong with 'dateunix' in connection with a timezone setting.
Maybe the intermediate variable precision is insufficient, cutting away a few hours and sliding into the previous day. Hopefully ciccio can say more to this.

I checked 'unixdate$', it works correctly.

With no timezone defined it seems to work correctly, strange.

Cheers

Ulli

Re: What day was yesterday?

Posted: Sat Jul 31, 2021 9:41 am
by Fernando Perez
Ulli, you got it right.
If I leave the "Time Zone" box blank and reset the system, unixDate$((dateUnix(date$) - 86400)) correctly calculates the previous day.
However, as is logical, now the instruction time$ returns a value 2 hours less than that of my time zone.
snake eating its own!
But I appreciate it, because we have already found out the cause. It was driving me crazy.

Re: What day was yesterday?

Posted: Sat Jul 31, 2021 2:34 pm
by ulli
Hi Fernando,

I tried at 16:30 CEST:

wlog unixdate$(dateunix(date$)-7100) results in 31/07/21

wlog unixdate$(dateunix(date$)-7300) results in 30/07/21

Wow! That should happen at about 2am! There's somthing severely wrong with dateunix.

Can you reproduce these results?

Cheers

Ulli

Re: What day was yesterday?

Posted: Sat Jul 31, 2021 6:21 pm
by Fernando Perez
Check made at 20:00 local time (Spain), that is, 18:00 UTC and with a blank "Time Zone" field on the configuration page:

wlog unixDate$(dateUnix(date$) - 86400) = 30/07/21
wlog unixdate$(dateunix(date$) - 7100) = 30/07/21
wlog unixdate$(dateunix(date$) - 7300) = 30/07/21

Check made at 20:00 local time (Spain), that is, 18:00 UTC and with CET-1CEST,M3.5.0,M10.5.0/3 in "Time Zone" field on the configuration page:

29/07/21
30/07/21
30/07/21