Modify

#3812 closed Bug (Fixed)

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

Reported by: matwachich@… Owned by: Jpm
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 Changed 15 months ago by Melba23

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 Changed 15 months ago by Jos

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 Changed 14 months ago by Jpm

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

comment:4 Changed 14 months ago by Jpm

  • Milestone set to 3.3.15.4
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [12502] in version: 3.3.15.4

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.