Hello,

the date parser of weblocks can failed if wrong numbers are used for the 
day, the month, the hours or the minutes.

The date parser use the encode-universal-time function wich throws an error 
(SIMPLE-TYPE-ERROR)
if, for example, the day number is grower than 31.

The result in weblocks is the well known alert popup :  'Oops, we could not 
complete your request because of an internal error.'

So , i have modified the date.lisp code to handle error :

(defun date->utime (day month year hour minute)
  (encode-universal-time 0 minute hour day month year))

(defmethod parse-view-field-value ((parser date-parser) value obj
                                   (view form-view) (field form-view-field) 
&rest args)
  (declare (ignore args))
  (if (text-input-present-p value)
      (multiple-value-bind (matched elements)
          (cl-ppcre:scan-to-strings 
"(\\d+)[\\-/\\.](\\d+)[\\-/\\.](\\d+)(\\s+(\\d+)[:\\.](\\d+))?" value)
        (when matched
+  (handler-case
          (let ((date (date->utime (parse-integer (aref elements 2) 
:junk-allowed t)
                                   (parse-integer (aref elements 1) 
:junk-allowed t)
                                   (parse-integer (aref elements 0) 
:junk-allowed t)
                                   (or (and (aref elements 4) 
(parse-integer (aref elements 4) :junk-allowed t)) 0)
                                   (or (and (aref elements 5) 
(parse-integer (aref elements 5) :junk-allowed t)) 0))))
            (when date (values t t date)))
+  (t () nil))))
      (values t (text-input-present-p value) value)))


Maybe it's not the right approach ?
What do you think about this ?

Thnaks.

Regards

-- 
You received this message because you are subscribed to the Google Groups 
"weblocks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/weblocks/-/uAgKvWBG_eAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/weblocks?hl=en.

Reply via email to