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:
Dim so As Long
so = DateTime.Now
Dim varx As Int
If DateTime.GetMonth(DateTime.Now) = 10 Then ' Checks if month = october
For p = 0 To 6 ' One Week = 7 days
so = DateTime.Add(DateTime.Now,0,0,p) ' Check every day in the following seven days
If DateTime.GetDayOfWeek(so) = 1 Then ' check if/when the next sunday comes
varx = DateTime.GetDayOfMonth(so) + 7
If (varx > 31) Then 'checks if this is the last sunday in the month
datumdiff = datumdiff - (3600 * 1000) ' - 1 hour
End If
End If
Next
End If
startserviceat(....datetime.now + datumdiff....)
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....