summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-05-07 23:56:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:48 -0500
commit62e910608614387dc694bed2baaaeddc3d71b1f0 (patch)
tree5747ef6ef5166b5883c21c8d19350aa6b065ed85 /source4
parent2fdf5d332d0a3c7a12fe4d7fdc0155dd7a45adc3 (diff)
downloadsamba-62e910608614387dc694bed2baaaeddc3d71b1f0.tar.gz
samba-62e910608614387dc694bed2baaaeddc3d71b1f0.tar.bz2
samba-62e910608614387dc694bed2baaaeddc3d71b1f0.zip
r576: added a ldap_timestring() function (needed for fields like whenChanged in SAM db)
(This used to be commit b2a63555189fea41184a2cac796945bca4e98995)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/time.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source4/lib/time.c b/source4/lib/time.c
index 0aef931fe0..0bc5fcd3fc 100644
--- a/source4/lib/time.c
+++ b/source4/lib/time.c
@@ -339,6 +339,25 @@ char *http_timestring(TALLOC_CTX *mem_ctx, time_t t)
return buf;
}
+/***************************************************************************
+return a LDAP time string
+ ***************************************************************************/
+char *ldap_timestring(TALLOC_CTX *mem_ctx, time_t t)
+{
+ struct tm *tm = gmtime(&t);
+
+ if (!tm) {
+ return NULL;
+ }
+
+ /* formatted like: 20040408072012.0Z */
+ return talloc_asprintf(mem_ctx,
+ "%04u%02u%02u%02u%02u%02u.0Z",
+ tm->tm_year+1900, tm->tm_mon+1,
+ tm->tm_mday, tm->tm_hour, tm->tm_min,
+ tm->tm_sec);
+}
+
/****************************************************************************