From bf65be54fa21aa3ae8cb9ed347bd72ff0347de6a Mon Sep 17 00:00:00 2001
From: goujonpa <goujonpa@gmail.com>
Date: Thu, 19 Jun 2014 02:24:51 +0200
Subject: [PATCH] =?UTF-8?q?datefield=20qui=20p=C3=A8te=20sa=20race?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 class/datefield.php | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/class/datefield.php b/class/datefield.php
index 801bcef..2af229e 100644
--- a/class/datefield.php
+++ b/class/datefield.php
@@ -13,11 +13,27 @@ class DateField extends Field
 
     public function validate()
     {
+        $ret = true;
         $this->value = $_POST[$this->name];
-        return true;
+        $year = substr($this->value, 0, 4);
+        $month = substr($this->value, 6, 2);
+        $day = substr($this->value, 9, 2);
+        $today = getdate();
+        if ($year < $today[year]) {
+            $ret = false;
+        } else if ( $year == $today[year] && $month < $today[mon] ){
+            $ret = false;
+        } else if ( $year == $today[year] && $month == $today[mon] && $day < $today[day]){
+            $ret = false;
+        }
+        return ret;
     }
 
     public function show() {
-        return $this->value; 
+        $year = substr($this->value, 0, 4);
+        $month = substr($this->value, 6, 2);
+        $day = substr($this->value, 9, 2);
+        $html = $day.'-'.$month.'-'.$year;
+        return $html; 
     }
 }
-- 
GitLab