General area when it fits no where else

Moderator: Mmiscool

User avatar
By heckler
#35322 Hey Forlotto,

Here is a date and time parser...
I don't know where the time is coming from and the time zone seems to be somewhere in the
??middle east??

but you should be able to adjust the hour to fit your needs with some simple math.

in this other thread... http://www.esp8266.com/viewtopic.php?f=41&t=6712&start=5
mmiscool states that the "time" command will likely change.

Code: Select allmemclear
cls
button "GetTime" [GetTime]
button "Exit " [Exit]
wait
[GetTime]
print time()
bla = time()

dw = mid(bla,1,3) 'dow
mh = mid(bla,5,3) 'month
dt = mid(bla,9,2) 'date
hh = mid(bla,12,2) 'hour
mm = mid(bla,15,2) 'min
ss = mid(bla,18,2) 'sec
yr = mid(bla,21,4) 'year

print dw
print mh
print dt
print hh
print mm
print ss
print yr
print
print "Heap"
print flashfree() 'how much mem left
wait
[Exit]
end


dwight
User avatar
By forlotto
#35417 interesting thanks...

Not so sure what mid and the numbers are doing would have to have a bit of time to study it further but looks small and compact.

Would be cool to check time every 15mins or so and setup a timer to do something at a specific time every week on a specific day aka weekly timer.

Maybe have a store of 7 weekly timers per day somehow I figured a RTC is required but really you could grab time and day and compare if - 20 minutes then set timer a loop that would execute every 15minutes to grab time and compare to a list of times and days. I'd almost bet it is possible to do somehow with the esp...

But thanks keep this kind of stuff coming!

BASIC ROCKS!
User avatar
By heckler
#35454 The mid() function allows you to pick apart and select certain characters in a string of characters.
So if you have the following stored in a variable (bla)... MON NOV 30 08:01:59 2015
then
Code: Select allmh = mid(bla,5,3)

assigns the characters starting at position 5 and for the next 3 characters to the variable mh
so you end up with mh = NOV

If you only care about certain parts of the time string then you can eliminate all the "mid()" functions that you don't care about.
If you just want hours then just keep hh and the mid() that selects the hours part of the time string.

I believe the documentation for the "mid()" function is a bit incorrect
where it says
mid():
Will return the string from the start position to the end position inside of the input string.
mid({string or var name},{Start position},{end position})

it should say ... mid({string or var name},{start position},{number of characters})

hope that helps
dwight
User avatar
By forlotto
#35469 nice string feature actually I like it ... Hrmmm almost makes me wonder if I can read the URL in this manner as well like msgget for instance this here could have some interesting uses.... Could have some passwords check for certain key words at different spots etc... Makes me believe I missed a tidbit of the documentation.

Thanks for this. Never did get to look at it but that pretty much takes the cake tis a busy season currently ;) Saved me a bit of reading don't get more direct than this.