Modify

Opened 5 years ago

Closed 5 years ago

#3812 closed Bug (Fixed)

_DateTimeSplit never returns @error, and thus, any bad formated datetime will pass

Reported by: matwachich@… Owned by: J-Paul Mesnage
Milestone: 3.3.15.4 Component: Documentation
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description

_DateTimeSplit doc states

Success: Date and Time into two separate Arrays. 
Failure: 0 and sets the @error flag to non-zero. 
@error: 1 - Invalid Input Date 

But you see the code of the function, the only return value is at the end and returns 1, without any error.

It seems that the function does not any check to the input string, so the documentation should not state that it does so.

I don't know if we should modify the documentation, or the function itself (makine it a bit more complexe to be able to check input).

Attachments (0)

Change History (4)

comment:1 by Melba23, 5 years ago

IMO the easiest way forward would be to add a single line to the function checking the date format:

If Not StringRegExp($sDate, "\d{4}[/.-]\d{2}[/.-]\d{2}[T ]\d{2}:\d{2}(:\d{2})?"( Then Return SetError(1, 0, 0)

But no doubt a real RegEx guru could come up with a better pattern.

M23

comment:2 by Jos, 5 years ago

I think the documentation is wrong and shouldn't state that @error is returned as this function really is used as an helper function and not intended to check for validity of the date.
You need to use _DateIsValid() for that. (which uses this UDF).
This is all written a very long time ago so there most likely could be many improvements made now we indeed have regex to our disposal. :)

comment:3 by J-Paul Mesnage, 5 years ago

I fix, I think, all your concerns "include" and doc about _DateIsvalid reference

comment:4 by J-Paul Mesnage, 5 years ago

Milestone: 3.3.15.4
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [12502] in version: 3.3.15.4

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.