Hello,
I want to get minutes count from current date-time to validate user account expiry(year-month-day-hour-min) I get date time from DS1302 with no problems at all, but the problem is the minutes count is wrong, it seems like variable overflows! any ideas how to correct this?
Thanks
I got the following result:
Current Date Time:2016\10\17-22:3
Minutes Products:4294959104-4294940544-24480-1320-3-4294958155
Yr should be, Yr = 2016 * 360 * 24 * 60 = 1045094400 not 4294959104
Mn should be, Mn = 10 * 30 * 24 * 60 = 432000 not 4294940544
I want to get minutes count from current date-time to validate user account expiry(year-month-day-hour-min) I get date time from DS1302 with no problems at all, but the problem is the minutes count is wrong, it seems like variable overflows! any ideas how to correct this?
Thanks
B4X:
Sub Process_Globals
Private Years As Int
Private Months As Byte
Private DayOfMonth As Byte
Private Hours As Byte
Private Minutes As Byte
Private Seconds As Byte
Private DayOfWeek As Byte
Private TimeTicks As ULong
Private MinutesSerial As ULong
B4X:
Sub DS1320timer_Tick()
'The current time must be defined in the sub. The global can not be used.
Dim currenttime As DSTime
currenttime = DS1302.CurrentTime
Years = currenttime.years
Months = currenttime.Months
DayOfMonth = currenttime.DayOfMonth
Hours = currenttime.Hours
Minutes = currenttime.Minutes
Seconds = currenttime.Seconds
DayOfWeek = currenttime.DayOfWeek
TimeTicks= TimeTicks + 1
Dim Yr As ULong = (Years) * (360) * (24) * (60)
Dim Mn As ULong = (Months) * (30) * (24) * (60)
Dim Dy As ULong = (DayOfMonth) * (24) * (60)
Dim Hr As ULong = (Hours) * (60)
MinutesSerial = Yr + Mn + Dy + Hr + Minutes
Log ("Current Date Time:",Years,"\",Months,"\",DayOfMonth,"-",Hours,":",Minutes)
Log ("Minutes Products:",Yr,"-",Mn,"-",Dy,"-",Hr,"-",Minutes,"-",MinutesSerial)
I got the following result:
Current Date Time:2016\10\17-22:3
Minutes Products:4294959104-4294940544-24480-1320-3-4294958155
Yr should be, Yr = 2016 * 360 * 24 * 60 = 1045094400 not 4294959104
Mn should be, Mn = 10 * 30 * 24 * 60 = 432000 not 4294940544