An archive of community.esquilo.io as of Saturday January 26, 2019.

Esquilo has wrong Date and Time

JefferyS

system("time")
2016-07-05T13:13:54-05
system("time zone")
-5
system("time")
2016-07-05T13:17:34-05

The time zone looks correct to me but the date is way off and so is the time.

What can I check?

I had the time server set to time.nist.gov but switched it back to esquilo.io before I took these readings. The time.nist.gov wasn't reading correctly either but don't remember what it showed as the date and time.

Running EOS 0.6

Ran this code:
require("system");

// Get the current local date/time
local t = date();

// Print the date
print(t.year + "-" + t.month + "-" + t.day + "\n");

// Print the time
print(t.hour + ":" + t.min + ":" + t.sec + "\n");

2016-6-5
13:7:23

Ran system("time") in the Ide and got this.
2016-07-05T13:07:30-05

Thanks,

Jeffery

JefferyS

I did some more checking today. The Esquilo is not able to query any time server I give it including esquilo.io. time.nist.gov, time-a.nist.gov, utcnist.colorado.edu

Says "Unable to query SNTP Server"

I am able to ping esquilo.io but not the other time servers I tried but couldn't ping them on my PC either.

I set the time on the Esquilo manually but when I ran my time.nut, shown above, the time was the same but the month was behind 1 month. Strange.

Thanks,

Jeffery

JefferyS

Just checked my Esquilo at home running EOS 0.6. It was able to query sntp.esquilo.io which I guess I have it wrong on the Esquilo at work. Had to set the time zone too, it was set to 0.

But running the test code, shown above,shows that it is also 1 month behind but the time is correct.

system("time") shows a date of 2016-09-10
The code above shows a date of 2016-8-10

Might be having a network issue at work but with try with the sntp.esquilo.io and see what happens.

Thanks,

Jeffery

JefferyS

Yes, it was some type of network issue, weird.

But the month is still behind one month in code compared to the system("time"), might be a bug.

Thanks,

Jeffery

Scott_Shumate

It sounds like they are blocking UDP connections at your workplace which is what NTP uses.

For the time, the months are numbered from 0 in the returned table. date() is a core Squirrel function so we kept the defined output format. This is the format:

Key Value
sec Seconds after minute (0 - 59)
min Minutes after hour (0 - 59)
hour Hour after midnight (0 - 23)
day Day of month (1 - 31)
month Month of year (0 - 11; 0 = January)
year Year
wday Day of week (0 - 6; 0 = Sunday)
yday Day of year (0 - 365; 0 = January 1)

See http://www.esquilo.io/docs/#squirrel-library-system for more.

JefferyS

Thanks Scott, I don't believe I have ever used a language that had the month start with 0.

So I have to add 1 to the month every time I use it.

Sorry I missed that in the Docs, Just doesn't make since to me to have a date function where the month starts with 0.

Guess I'll have to go change all my code that puts a date into a log or something.

Thanks,

Jeffery

gwittie

Jeffery,
It makes sense when you access an array with the month names as strings. Arrays will start from 0 to 11 so the values returned will make this easier. Same would apply to days of the week.

Gary

JefferyS

Thanks Gary, I completely understand what you are saying but I look at it this way, when ever you put the date into a log or database or anything like that they don't use the month names.

Where you see the month name is usually when a user is looking at a report or may be on their screen and such.

So why have to spend all that trouble adding 1 to the month every time you want to enter the date into a log or database which happens a whole lot. I think it would benefit the programmer more not to have to mess with that and only mess with it when they want to display the name of the month for the user.

Adding a dummy value say "Months" in index 0 in an array of month names would be tons easier than having to add 1 to the month every time you use it.

It will probably never change in Squirrel or Java which is fine but at least I know why the month is off and can adjust for it.

I will probably add a function that does that so I don't have + 1's all in my code.

Thanks,

Jeffery