iOS Question Error parsing 31/03/2024 ???

ilan

Expert
Licensed User
Longtime User
hi

just noticed that my app is crashing. opened b4i and checked why. it seems like b4i cannot parse the date 31/03/2024.
why is that?

code:

B4X:
DateTime.DateFormat = "dd/MM/yyyy"
Log(DateTime.DateParse("31/03/2024"))

log:

Application_Start
*** mainpage: B4XPage_Created
Application_Active
*** mainpage: B4XPage_Appear [mainpage]
*** mainpage: B4XPage_Resize [mainpage]
*** shoppinglist: B4XPage_Created [mainpage]
Error occurred on line: 555 (ShabatModule)
Error parsing: 31/03/2024
Stack Trace: (
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 969524
libobjc.A.dylib objc_exception_throw + 60
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 1516196
result -[B4IDateTime DateParse:] + 136
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 203908
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 202512
result +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
result -[B4IShell runMethod:] + 320
result -[B4IShell raiseEventImpl:method:args::] + 928
result -[B4IShellBI raiseEvent:event:params:] + 1008
result -[b4i_shabatmodule _issummertime:] + 248
result -[b4i_shabatmodule _sunsettime:] + 668
result -[b4i_shabatmodule _allowads:] + 424
result -[ResumableSub_shoppinglist_B4XPage_Created resume::] + 972
result -[b4i_shoppinglist _b4xpage_created::] + 412
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 203908
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 202512
result +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
result -[B4ICommon CallSubDebug4::::] + 848
result -[B4ICommon CallSubDebug2::::] + 272
result -[b4i_b4xpagesmanager _createpageifneeded::] + 888
result -[b4i_b4xpagesmanager _addpageandcreate:::] + 580
result -[b4i_b4xpages _addpageandcreate::] + 468
result -[ResumableSub_b4xmainpage_B4XPage_Created resume::] + 1792
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 203908
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 202512
result +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
result -[B4IShell runMethod:] + 320
result -[B4IShell raiseEventImpl:method:args::] + 928
result -[B4IShellBI raiseEvent:event:params:] + 1008
result -[B4IDelegatableResumableSub resume::] + 336
result -[B4I checkAndRunWaitForEvent:event:params:] + 468
result -[B4IShellBI raiseEvent:event:params:] + 904
result __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
libdispatch.dylib B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 8508
libdispatch.dylib B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 15828
libdispatch.dylib B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 75172
libdispatch.dylib _dispatch_main_queue_callback_4CF + 44
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 226588
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 213528
CoreFoundation CFRunLoopRunSpecific + 608
GraphicsServices GSEventRunModal + 164
UIKitCore 7BF01CFC-23F1-326A-AFD8-AD967FFECE28 + 2272988
UIKitCore UIApplicationMain + 340
result main + 100
dyld 7BE2B757-3B3D-3E91-8CB7-74F3887660C7 + 23940
)
 

Alex_197

Well-Known Member
Licensed User
Longtime User
I tested it on my US based iPhone 11 iOS 17.3.1 abd it works - see attached
 

Attachments

  • DateTest.zip
    2.2 KB · Views: 19
Upvote 0

emexes

Expert
Licensed User
Try adding related Logs that might give clues eg:
B4X:
DateTime.DateFormat = "dd/MM/yyyy"
Log(DateTime.DateFormat)                 'maybe it's stuck at default??? no idea why that would be, but still worth checking
Log(DateTime.Date(DateTime.Now))         'check whether 24/03 or 03/24
Log(DateTime.DateParse("05/03/2024"))
Log(DateTime.DateParse("03/05/2024"))    'this should be greater than the previous number (by 59 days x 86400 x 1000 = tad over 5 billion)
Log(DateTime.DateParse("15/02/2024"))
Log(DateTime.DateParse("31/03/2024"))
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
for some reason it is not working for me. other dates are fine. 31/03/2024 is crashing :(

B4X:
Copying updated assets files (46)
Application_Start
*** mainpage: B4XPage_Created
Error occurred on line: 50 (B4XMainPage)
Error parsing: 31/03/2024
Stack Trace: (
  CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 969524
  libobjc.A.dylib      objc_exception_throw + 60
  CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 1516196
  result               -[B4IDateTime DateParse:] + 136
  result               -[ResumableSub_b4xmainpage_B4XPage_Created resume::] + 704
  result               -[b4i_b4xmainpage _b4xpage_created::] + 412
  CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 203908
  CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 202512
  result               +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
  result               -[B4ICommon CallSubDebug4::::] + 848
 result               -[B4ICommon CallSubDebug2::::] + 272
 result               -[b4i_b4xpagesmanager _createpageifneeded::] + 888
 result               -[b4i_b4xpagesmanager _showpage::] + 636
 result               -[b4i_b4xpagesmanager _addpage:::] + 1116
 result               -[b4i_b4xpagesmanager _addpageandcreate:::] + 488
 result               -[b4i_b4xpagesmanager _initialize:::] + 1408
 result               -[b4i_main _application_start:] + 1244
 CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 203908
 CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 202512
 result               +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
 result               -[B4IShell runMethod:] + 320
 result               -[B4IShell raiseEventImpl:method:args::] + 928
 result               -[B4IShellBI raiseEvent:event:params:] + 1008
 result               __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
 libdispatch.dylib    B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 8508
 libdispatch.dylib    B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 15828
 libdispatch.dylib    B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 75172
 libdispatch.dylib    _dispatch_main_queue_callback_4CF + 44
 CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 226588
 CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 213528
 CoreFoundation       CFRunLoopRunSpecific + 608
 GraphicsServices     GSEventRunModal + 164
 UIKitCore            7BF01CFC-23F1-326A-AFD8-AD967FFECE28 + 2272988
 UIKitCore            UIApplicationMain + 340
 result               main + 100
 dyld                 7BE2B757-3B3D-3E91-8CB7-74F3887660C7 + 23940
)
Application_Active
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
even if i create a new b4i project (default) and add the code at application start:

B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 8
#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 App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private xui As XUI
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Page1")
    NavControl.ShowPage(Page1)
  
    DateTime.DateFormat = "dd/MM/yyyy"
    Log(DateTime.DateParse("31/03/2024"))
End Sub

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
  
End Sub

this is a fresh new project i get the same error:

B4X:
Copying updated assets files (1)
Application_Start
Error occurred on line: 32 (Main)
Error parsing: 31/03/2024
Stack Trace: (
  CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 969524
  libobjc.A.dylib      objc_exception_throw + 60
  CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 1516196
  B4i Example          -[B4IDateTime DateParse:] + 136
  B4i Example          -[b4i_main _application_start:] + 944
  CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 203908
  CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 202512
  B4i Example          +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
  B4i Example          -[B4IShell runMethod:] + 320
  B4i Example          -[B4IShell raiseEventImpl:method:args::] + 928
 B4i Example          -[B4IShellBI raiseEvent:event:params:] + 1008
 B4i Example          __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
 libdispatch.dylib    B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 8508
 libdispatch.dylib    B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 15828
 libdispatch.dylib    B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 75172
 libdispatch.dylib    _dispatch_main_queue_callback_4CF + 44
 CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 226588
 CoreFoundation       3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 213528
 CoreFoundation       CFRunLoopRunSpecific + 608
 GraphicsServices     GSEventRunModal + 164
 UIKitCore            7BF01CFC-23F1-326A-AFD8-AD967FFECE28 + 2272988
 UIKitCore            UIApplicationMain + 340
 B4i Example          main + 100
 dyld                 7BE2B757-3B3D-3E91-8CB7-74F3887660C7 + 23940
)
Application_Active

it happens on my iphone 15 and also on iphone 11. ios 17.4.1

i cant explain why it is happening but it happens to 2 different phone i tried. are you guys trying it on real device or simulator? i am trying it on real devices.
 
Upvote 0

emexes

Expert
Licensed User
Is there a summer-time winter-time changeover on 31/3 or maybe 1/4 ?

Although usually they are early in the morning rather than bang-on midnight, so... 🤔

Lol or a leap second? Although I thought they're only at six-month boundaries and the earth had stopped slowing down anyway, so again... 🤔
 
Upvote 0

emexes

Expert
Licensed User
Clutching at straws, but what happens with:
B4X:
DateTime.DateFormat = "dd/MM/yyyy HH"
Log(DateTime.DateParse("31/03/2024" & " 04"))    'note space before 04
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
For whatever it may help, 31/3/2024 (at 1:00 UTC) will start Daylight Saving Time at most European countries
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
even if i create a new b4i project (default) and add the code at application start:

B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 8
#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 App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private xui As XUI
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Page1")
    NavControl.ShowPage(Page1)
 
    DateTime.DateFormat = "dd/MM/yyyy"
    Log(DateTime.DateParse("31/03/2024"))
End Sub

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
 
End Sub

Runs fine on my phone (XR with iOS 17.4)
 
Upvote 0

emexes

Expert
Licensed User
Another idea, look closely at times 11pm to 4am around the midnights at each side of 31/03:
B4X:
DateTime.DateFprmat = "dd/MM/yyyy HH:mm:ss"
For T = DateTime.Now To DateTime.Now + 10 * 86400 * 1000 step 600000    '600 seconds = 10 minutes
    Log(T & Tab & DateTime.Date(T) & Tab)
Next
because the obvious explanation for it working everywhere else is that it is something to do with your locale or timezone.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
hi @emexes

because the crash happened only on that date i did not investigate it further.
although if i try your code like this:

B4X:
    DateTime.DateFormat = "dd/MM/yyyy HH"
    Log(DateTime.DateParse("31/03/2024" & " 04"))    'note space before 04

there is no crash

Application_Start
*** mainpage: B4XPage_Created
1711846800000
Application_Active

but without the HH

B4X:
    DateTime.DateFormat = "dd/MM/yyyy"
    Log(DateTime.DateParse("31/03/2024"))

it still crashes

Application_Start
*** mainpage: B4XPage_Created
Error occurred on line: 50 (B4XMainPage)
Error parsing: 31/03/2024
Stack Trace: (
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 969524
libobjc.A.dylib objc_exception_throw + 60
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 1516196
result -[B4IDateTime DateParse:] + 136
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 203908
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 202512
result +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
result -[B4IShell runMethod:] + 320
result -[B4IShell raiseEventImpl:method:args::] + 928
result -[B4IShellBI raiseEvent:event:params:] + 1008
result -[b4i_b4xmainpage _b4xpage_created::] + 268
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 203908
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 202512
result +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
result -[B4ICommon CallSubDebug4::::] + 848
result -[B4ICommon CallSubDebug2::::] + 272
result -[b4i_b4xpagesmanager _createpageifneeded::] + 888
result -[b4i_b4xpagesmanager _showpage::] + 636
result -[b4i_b4xpagesmanager _addpage:::] + 1116
result -[b4i_b4xpagesmanager _addpageandcreate:::] + 488
result -[b4i_b4xpagesmanager _initialize:::] + 1408
result -[b4i_main _application_start:] + 1244
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 203908
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 202512
result +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
result -[B4IShell runMethod:] + 320
result -[B4IShell raiseEventImpl:method:args::] + 928
result -[B4IShellBI raiseEvent:event:params:] + 1008
result __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
libdispatch.dylib B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 8508
libdispatch.dylib B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 15828
libdispatch.dylib B7D9D0A6-2414-37F2-9D03-1A25A474E2CF + 75172
libdispatch.dylib _dispatch_main_queue_callback_4CF + 44
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 226588
CoreFoundation 3A5F992A-D1CD-312E-BD2E-F7C66343A417 + 213528
CoreFoundation CFRunLoopRunSpecific + 608
GraphicsServices GSEventRunModal + 164
UIKitCore 7BF01CFC-23F1-326A-AFD8-AD967FFECE28 + 2272988
UIKitCore UIApplicationMain + 340
result main + 100
dyld 7BE2B757-3B3D-3E91-8CB7-74F3887660C7 + 23940
)
Application_Active

it is weird that it is working for Erel since he is also from the same country as i am, I guess you are right it has something to do with the summer time change over.
Thank you very much for your support and effort 🙏🙏🙏 (sorry that i could not check it earlier i am very busy lately)
 
Upvote 0

emexes

Expert
Licensed User
it is weird that it is working for Erel since he is also from the same country as i am.

For some reason I thought you were from Turkey.

At least now you have a heads-up that you might be hearing from some of your apps' users on 31/03. Happily it is a Sunday ie not a business day, so that might help keep "serious" inconvenience to a minimum.

If you go to the Android phone's Settings, (System,) Date and time, does it tell you what time zone it thinks it is in? Some phones, if they're in automatic get-time-zone-from-(phone)-network mode, you might need to temporarily switch to manual mode to see what's going on.

eg my time zone here currently shows as "GMT +11:00 Australian Eastern Daylight Time" which looks correct because at longitude 145 degrees from GMT we are nominally 9h40m ahead of GMT at longitude 0, which rounds off to 10 hours, plus another hour because we're on summer time at the moment.

I can see that parsing "29/03/2024 02:30" might be a problem if your time zone is set to Israel, because that particular time should never appear on a clock in Israel because they are due to jump from 2am IST to 3am IDT.


But parsing midnight ie "29/03/2024 00:00" should be ok, and parsing any time on 31/03/2024 should be ok too because there is no time jump on that day (because it should already have happened 2 days earlier, on 29/03/2024).
 
Upvote 0

emexes

Expert
Licensed User
Sorry, that was a lot of writing when the crux was that with:

what time zone it thinks it is in?

then maybe the problem can be reproduced by others,

which is a good halfway closer to understanding what's going on,

and perhaps also closer to a better solution than my more-arse-than-class guess. 🤣
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
But parsing midnight ie "29/03/2024 00:00" should be ok, and parsing any time on 31/03/2024 should be ok too because there is no time jump on that day (because it should already have happened 2 days earlier, on 29/03/2024).
yes i agree but it crashes for some reason. i dont understand why it is happening. i will need to investigate it further to understand how to make sure it is not happening for other apps.
 
Upvote 0
Top