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

Capture new “time get” into a variable?

gwittie

How do I capture the console output from the new system("time get") command and put it into a variable that can be operated on in a nut file?

Scott_Shumate

The "time get" command is really meant for use interactively from the USB or telnet shell. If you want the time and date in Squirrel, then use the date() command and you'll get back a table full of variables. See the docs for date() here:

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

By default Esquilo uses GMT time. In the 0.3beta1 you can now set a timezone using the "time zone " command and the timezone will be permanently saved in EEPROM and returned by the date() command.

gwittie

I tried the date() command and did not get the correct month value. Here is an output from the reading of the date(time(),'l'); command along with the system("time") and system("time get"); commands... Note the month is 7 (July) instead of 8 (Aug) for the date(time()) command. All other date parameters are correct according to the time zone setup (-5 for CST-DST).

Running nut 'sd:/Projects/DateTime/date_time_v0.nut'.
Local time(CST-DST):
2015-7-9 T 14:24:11
UTC time:
2015-7-9 T 19:24:11
Squirrel time call: 1439148251
System time: 2015-08-09T14:24:11-05
System time get: 2015-08-09T14:24:11-05

Scott_Shumate

In the Squirrel system library, the months start at 0 instead of 1. (0 = January) Your guess is as good as mine why this was done. The day of the month starts at 1. Go figure.