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

What day was yesterday?

Post by Fernando Perez »

How can I find out what day it was yesterday?
I thought of using this:

Code: [Local Link Removed for Guests]

day$ = unixDate$((dateUnix(date$) - 86400))
wlog day$
But it always returns the date two days ago, not just one.
Why is this happening?
Can you think of anything to correct it?
cicciocb
Site Admin
Posts: 401
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 90 times
Been thanked: 290 times
Contact:

Re: What day was yesterday?

Post by cicciocb »

Hi Fernand,
It seems right and I have the good result on both ESP8266 and ESP32.

Have you the right Time Zone set in the config page?
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 »

Good morning Cicciocb.
I am in Spain and I have configured:

CET-1CEST,M3.5.0,M10.5.0/3

Can it be a conflict of my time zone with Annex?
I previously had this problem:

[External Link Removed for Guests]
cicciocb
Site Admin
Posts: 401
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 90 times
Been thanked: 290 times
Contact:

Re: What day was yesterday?

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Fri Jul 30, 2021 11:03 am Good morning Cicciocb.
I am in Spain and I have configured:

CET-1CEST,M3.5.0,M10.5.0/3

Can it be a conflict of my time zone with Annex?
I previously had this problem:

[External Link Removed for Guests]
The time zone seems OK.
I have the right information right now on both ESP8266 and ESP32.
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 »

Yes, it seems strange. Can someone else confirm what is happening in your area / device?
Thanks.
image.png
You do not have the required permissions to view the files attached to this post.
cicciocb
Site Admin
Posts: 401
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 90 times
Been thanked: 290 times
Contact:

Re: What day was yesterday?

Post by cicciocb »

These are my results :
image.png
image.png
What Annex version are you using ?
You do not have the required permissions to view the files attached to this post.
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 »

version 1.43.2 in ESP8266 Wemos D1 mini
Any other easy way to find out a date by subtracting or adding a number of days to the current date?
Without using unixdate and dateunix?
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 »

Marcello, I am afraid to be heavy, but it is important for an ongoing project.
Until now I thought that the optional parameter of the date$ function was solely for the purposes of the date display format (D/M/Y, M/D/Y and Y/M/D), but I see this:

Code: [Local Link Removed for Guests]

wlog "European", date$(0), str$(dateunix(date$(0)), "%10.0f")
wlog "American", date$(1), str$(dateunix(date$(1)), "%10.0f")
wlog "Canadian", date$(2), str$(dateunix(date$(2)), "%10.0f")
image.png
"dateUnix returns the number of seconds from 01/01/1970 to the specified date"

Shouldn't this number of seconds be the same regardless of the country?
You do not have the required permissions to view the files attached to this post.
ebs
Posts: 14
Joined: Fri Jun 25, 2021 2:33 pm
Been thanked: 2 times

Re: What day was yesterday?

Post by ebs »

Hi Fernando,

So it appears that the "dateunix()" function works only for the European (D/M/Y) date format, right?
That's a very good thing to know before doing any date math - thanks.

Regards,
Eric
ulli
Posts: 12
Joined: Tue Feb 09, 2021 9:48 am
Been thanked: 2 times

Re: What day was yesterday?

Post by ulli »

Hi Eric, hi Fernando,

RTFM (Read The Fine Manual): DATEUNIX(date$) converts a date in format dd/mm/yy into UNIX FORMAT.

So your conversion examples are

European 30/07/21 30. day of July 2021 (today)
American 07/30/21 7. day of Trigintember (????) 2021 (some Klingon calendar)
Canadian 21/07/30 21. day of July 2030 (in a couple of years)

That's why the numbers are so different.

Cheers

Ulli
Post Reply