Skip to content

Custom datetime parsing function that doesn't use try/catch #25

@apjanke

Description

@apjanke

Matlab's own datetime parsing logic uses try/catch in the happy path, which means you can't use dbstop if all error when parsing datetimes.

>> dbstop if all error
>> dt = datetime('2019-01-01 03:42')

Caught-error breakpoint was hit in @datetime/private/guessFormat>tryOneFmt at line 154. The error was:

Error using matlab.internal.datetime.createFromString
Unable to convert the text to datetime using the format 'dd-MMM-uuuu HH:mm:ss'.

154             t = createFromString(tryStr,fmt,2,tz,locale,pivot); % error, don't return NaT
K>> dbstack
> In guessFormat/tryOneFmt (line 154)
  In guessFormat (line 43)
  In datetime (line 632)

Write a replacement for datetime(str) that doesn't use try/catch. And then use that everywhere in Janklab's code.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions