2 /*******************************************************************************
3 * Copyright (C) 2007 Easter-eggs
4 * http://ldapsaisie.labs.libre-entreprise.org
6 * Author: See AUTHORS file in top-level directory.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ******************************************************************************/
24 * Type d'attribut Ldap date
27 class LSattr_ldap_date extends LSattr_ldap {
30 * Retourne la valeur d'affichage de l'attribut après traitement lié à son type ldap
32 * @param[in] $data mixed La valeur de l'attribut
34 * @retval mixed La valeur d'affichage de l'attribut
36 function getDisplayValue($data) {
37 if(!is_array($data)) {
40 if ($this -> config['ldap_options']['timestamp']==1) {
44 foreach($data as $val) {
45 $date = strptime($val,$this -> getFormat());
46 if (is_array($date)) {
47 $retval[] = mktime($date['tm_hour'],$date['tm_min'],$date['tm_sec'],$date['tm_mon']+1,$date['tm_mday'],$date['tm_year']+1900);
54 * Retourne la valeur de l'attribut après traitement lié à son type ldap
56 * @param[in] $data mixed La valeur de l'attribut
58 * @retval mixed La valeur traitée de l'attribut
60 function getUpdateData($data) {
61 if ($this -> config['ldap_options']['timestamp']==1) {
66 foreach($data as $val) {
67 $retval[] = strftime($this -> getFormat(),$val);
74 * Retourne le format de stockage de la date
76 * @retval string Le format de la date
78 function getFormat() {
79 if (isset($this -> config['ldap_options']['format'])) {
80 return $this -> config['ldap_options']['format'];
83 return "%Y%m%d%H%M%SZ";