Bug? DateUtils - Crash when 24-Hour time turned off

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
I have the following lines of code.
B4X:
    Private dy,mt,yr As Int
    dy = DateTime.GetDayOfMonth(DateTime.Now)
    mt = DateTime.GetMonth(DateTime.Now)
    yr = DateTime.GetYear(DateTime.Now)
    calrng.RangeStart = DateUtils.SetDate(yr,mt,dy)

This code works perfectly if in
Settings -> General -> Date & Time -> 24-Hour Time is turned on

If you turn if off I get a crash on the SetDate
Error: Invalid value: AD20190520 000000
Error occurred on line: 183 (CalendarEventCache)
Cannot parse: invalid date
Stack Trace: (
CoreFoundation <redacted> + 148
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation <redacted> + 0
Book That In -[B4I ObjectToNumber:] + 464
Book That In -[b4i_dateutils _setdateandtime::::::] + 2344
Book That In -[b4i_dateutils _setdate:::] + 80
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 292
Book That In +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
Book That In -[B4IShell runMethod:] + 448
Book That In -[B4IShell raiseEventImpl:method:args::] + 1648
Book That In -[B4IShellBI raiseEvent:event:params:] + 1580
Book That In +[B4IDebug delegate:::] + 80
Book That In -[b4i_calendareventcache _storelocalcalendars:] + 228
Book That In -[ResumableSub_splashlogin_SA_GetAllUCalendars resume::] + 1972
Book That In -[b4i_splashlogin _sa_getallucalendars:] + 560
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 292
Book That In +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
Book That In -[B4IShell runMethod:] + 448
Book That In -[B4IShell raiseEventImpl:method:args::] + 2172
Book That In -[B4IShellBI raiseEvent:event:params:] + 1580
Book That In __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
libdispatch.dylib <redacted> + 24
libdispatch.dylib <redacted> + 16
libdispatch.dylib <redacted> + 1016
CoreFoundation <redacted> + 12
CoreFoundation <redacted> + 2012
CoreFoundation CFRunLoopRunSpecific + 436
GraphicsServices GSEventRunModal + 100
UIKit UIApplicationMain + 208
Book That In main + 124
libdyld.dylib <redacted> + 4
)

Any Ideas?
 
Top