I*m making an app for shift workers...the apps is including an alarm to wake up.
So here is how it should work:
There s a service modul running in the background with service startforeground. its calculating the next awakening time, calls itself again and if datetime.now = alarm time then plays an awakening sound.
so far so good. The only problem is: its an app for german shiftworkers, so i have a little problem with the wintertime, summertime issue.
i tried to fix it with the following code:
This lines should check if the last sunday in october is between the time now and the sheduled alarm time.
Could you do me a favour and look over it with your b4a professional eyes? Because its hard to test if it works....
So here is how it should work:
There s a service modul running in the background with service startforeground. its calculating the next awakening time, calls itself again and if datetime.now = alarm time then plays an awakening sound.
so far so good. The only problem is: its an app for german shiftworkers, so i have a little problem with the wintertime, summertime issue.
i tried to fix it with the following code:
B4X:
Dim so As Long
so = DateTime.Now
Dim varx As Int
If DateTime.GetMonth(DateTime.Now) = 10 Then
For p = 0 To 6
so = DateTime.Add(DateTime.Now,0,0,p)
If DateTime.GetDayOfWeek(so) = 1 Then
varx = DateTime.GetDayOfMonth(so) + 7
If (varx > 31) Then
datumdiff = datumdiff - (3600 * 1000)
End If
End If
Next
End If
startserviceat(....datetime.now + datumdiff....)
Could you do me a favour and look over it with your b4a professional eyes? Because its hard to test if it works....