X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/db3b46cbba6ebce2f4dd3b4b7cbd841d575cf3b9..bf12489aa5ecb02b7be66367e0b2ec1cd9c35bae:/src/slot-presentations/date.lisp diff --git a/src/slot-presentations/date.lisp b/src/slot-presentations/date.lisp index 04d93ff..161b31c 100644 --- a/src/slot-presentations/date.lisp +++ b/src/slot-presentations/date.lisp @@ -42,15 +42,38 @@ -(defcomponent %integer-range-field (ucw::integer-range-field) +(defcomponent %integer-range-field (integer-range-field) ()) (defmethod (setf lisp-value) :after (value (self %integer-range-field)) ()) - - +(defclass date-field (form-element) + ((day :component (integer-range-field :min-value 1 :max-value 31)) + (month :component (integer-range-field :min-value 1 :max-value 12)) + (year :component integer-range-field)) + (:metaclass standard-component-class)) + +(defmethod shared-initialize :after ((field date-field) slot-names + &key (year-min 1960) (year-max 2010)) + (declare (ignore slot-names)) + (setf (min-value (slot-value field 'year)) year-min + (max-value (slot-value field 'year)) year-max + (max-value (slot-value field 'day)) 31 + (max-value (slot-value field 'month)) 12)) + +(defmethod read-client-value ((date date-field)) + (with-slots (year month day) + date + (read-client-value year) + (read-client-value month) + (read-client-value day) + (setf (lisp-value date) (encode-universal-time 0 0 0 + (lisp-value day) + (lisp-value month) + (lisp-value year))))) -(defclass %date-field (ucw::date-field) + +(defclass %date-field (date-field) ((day :component (%integer-range-field :min-value 1 :max-value 31)) (month :component (%integer-range-field :min-value 1 :max-value 12)) (year :component (%integer-range-field :min-value 2005 :max-value 2015) )) @@ -73,3 +96,149 @@ "/" (