What day was yesterday?

Recurrent H/W and software problems
User avatar
Fernando Perez
Posts: 118
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 62 times
Been thanked: 67 times

Re: What day was yesterday?

Post 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$
ulli
Posts: 12
Joined: Tue Feb 09, 2021 9:48 am
Been thanked: 2 times

Re: What day was yesterday?

Post by ulli »

Hi Fernando,

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

Cheers

Ulli
User avatar
Fernando Perez
Posts: 118
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 62 times
Been thanked: 67 times

Re: What day was yesterday?

Post 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
ulli
Posts: 12
Joined: Tue Feb 09, 2021 9:48 am
Been thanked: 2 times

Re: What day was yesterday?

Post 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
User avatar
Fernando Perez
Posts: 118
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 62 times
Been thanked: 67 times

Re: What day was yesterday?

Post 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.
ulli
Posts: 12
Joined: Tue Feb 09, 2021 9:48 am
Been thanked: 2 times

Re: What day was yesterday?

Post 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
User avatar
Fernando Perez
Posts: 118
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 62 times
Been thanked: 67 times

Re: What day was yesterday?

Post 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
Post Reply