diff --git a/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap_date.docbook b/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap_date.docbook
index 8be3a5cc..3c9ebc67 100644
--- a/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap_date.docbook
+++ b/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap_date.docbook
@@ -7,7 +7,8 @@
Structure...
array (
'timestamp' => [Booléen], // Si la date est stockée au format timestamp
- 'format' => '[Format de stockage]' // Default : "%Y%m%d%H%M%SZ"
+ 'format' => '[Format de stockage]', // Default : "YmdHisO"
+ 'timezone' => '[Fuseau horaire]', // Default : "UTC"
),]]>
...
@@ -30,12 +31,27 @@
format
Format de stockage de la date dans l'annuaire. Ce format est composé à
- partir des motifs clés gérés par la fonction strftime()
+ partir des motifs clés gérés par la fonction date()
de &php;. Pour plus d'information, consulter
- la documentation officielle.
- La valeur par défaut est %Y%m%d%H%M%SZ,
- correspondant au format de stockage par défaut dans &openldap;. Exemple :
- 20091206230506Z
+ la documentation officielle.
+ La valeur par défaut est YmdHisO,
+ correspondant à la syntaxe Generalized Time telle que
+ définie dans la RFC4517
+ . Exemples : 20091206230506Z
+ (=2009/12/06 23:05:66 UTC) ou
+ 20190613143537+0200
+ (=2019/06/13 14:35:37 UTC+0200).
+
+
+
+
+
+
+ timezone
+
+ Fuseau horaire de stockage des dates dans l'annuaire LDAP. Les valeurs
+ possibles sont documentées dans la
+ documentation officielle de PHP. (Par défaut : UTC)
diff --git a/public_html/core.php b/public_html/core.php
index 39249f15..9d36bc02 100644
--- a/public_html/core.php
+++ b/public_html/core.php
@@ -55,9 +55,6 @@ define('LS_LOCAL_DIR', 'local/');
define('LS_TEXT_DOMAIN', 'ldapsaisie');
define('LS_I18N_DIR', 'lang');
-// Timezone
-date_default_timezone_set('UTC');
-
require_once LS_INCLUDE_DIR.'functions.php';
require_once LS_CLASS_DIR.'class.LSsession.php';
diff --git a/public_html/includes/class/class.LSattr_ldap_date.php b/public_html/includes/class/class.LSattr_ldap_date.php
index 24708e84..4e9f5c8c 100644
--- a/public_html/includes/class/class.LSattr_ldap_date.php
+++ b/public_html/includes/class/class.LSattr_ldap_date.php
@@ -42,9 +42,9 @@ class LSattr_ldap_date extends LSattr_ldap {
}
$retval=array();
foreach($data as $val) {
- $date = strptime($val,$this -> getFormat());
- if (is_array($date)) {
- $retval[] = mktime($date['tm_hour'],$date['tm_min'],$date['tm_sec'],$date['tm_mon']+1,$date['tm_mday'],$date['tm_year']+1900);
+ $datetime = date_create_from_format($this -> getFormat(), $val);
+ if (is_a($datetime, DateTime)) {
+ $retval[] = $datetime -> format('U');
}
}
return $retval;
@@ -61,10 +61,18 @@ class LSattr_ldap_date extends LSattr_ldap {
if ($this -> getConfig('ldap_options.timestamp', false, 'bool')) {
return $data;
}
+ $timezone = timezone_open($this -> getConfig('ldap_options.timezone', 'UTC', 'string'));
$retval=array();
if(is_array($data)) {
foreach($data as $val) {
- $retval[] = strftime($this -> getFormat(),$val);
+ $datetime = date_create("@$val");
+ $datetime -> setTimezone($timezone);
+ $datetime_string = $datetime -> format($this -> getFormat());
+
+ // Replace +0000 or -0000 end by Z
+ $datetime_string = preg_replace('/[\+\-]0000$/', 'Z', $datetime_string);
+
+ $retval[] = $datetime_string;
}
}
return $retval;
@@ -76,7 +84,7 @@ class LSattr_ldap_date extends LSattr_ldap {
* @retval string Le format de la date
**/
public function getFormat() {
- return $this -> getConfig('ldap_options.format', '%Y%m%d%H%M%SZ');
+ return $this -> getConfig('ldap_options.format', 'YmdHisO');
}
}