diff options
-rw-r--r-- | source4/lib/time.c | 19 |
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); +} + /**************************************************************************** |