#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Public timelib As ESPTimetools
Public wifi As ESP8266WiFi
Public timestamp As ULong
End Sub
' based on the following Libraries:
' https://github.com/aharshac/EasyNTPClient
' https://github.com/PaulStoffregen/Time
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
wifi.Connect2("insert your wifi id","insert your wifi password")
timelib.initialize("pool.ntp.org",3600) 'UTC(1) = MEZ
timestamp=timelib.timestamp
If timestamp <> 0 Then
Log ("Timestamp is:", timestamp)
If (timelib.issummertime_eu(timelib.getyear(timestamp),timelib.getmonth(timestamp),timelib.getday(timestamp),timelib.gethour(timestamp),1))=True Then
timestamp=timestamp+3600 'UTC(1) = MEZ +3600sec (1hour) = MESZ
Log ("it is summertime")
Else
Log ("it is wintertime")
End If
Log("Seconds ",timelib.getseconds(timestamp))
Log("minute ",timelib.getminute(timestamp))
Log("hour ",timelib.gethour(timestamp))
Log("weekday ",timelib.getweekday(timestamp))
Log("day ",timelib.getday(timestamp))
Log("month ",timelib.getmonth(timestamp))
Log("year ",timelib.getyear(timestamp))
Log("hour12 ",timelib.gethour12(timestamp))
Log("Is AM ",timelib.isam(timestamp))
Log("Is PM ",timelib.ispm(timestamp))
' date & time formatet
Log("Date: ",NumberFormat(timelib.getday(timestamp),2,0),".",NumberFormat(timelib.getmonth(timestamp),2,0),".",timelib.getyear(timestamp))
Log("Time: ",NumberFormat(timelib.gethour(timestamp),2,0),":",NumberFormat(timelib.getminute(timestamp),2,0),":",NumberFormat(timelib.getseconds(timestamp),2,0))
Else
Log ("error: can't get time data from server")
End If
End Sub