diff options
author | Gerald Carter <jerry@samba.org> | 2005-03-23 23:26:33 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:56:15 -0500 |
commit | 5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c (patch) | |
tree | 12142ce30c28b602882cb6c3492dfc5811a7eace /source3/lib/time.c | |
parent | 920745f0df024741f28e8557c52187a8db01c5d1 (diff) | |
download | samba-5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c.tar.gz samba-5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c.tar.bz2 samba-5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c.zip |
r6014: rather large change set....
pulling back all recent rpc changes from trunk into
3.0. I've tested a compile and so don't think I've missed
any files. But if so, just mail me and I'll clean backup
in a couple of hours.
Changes include \winreg, \eventlog, \svcctl, and
general parse_misc.c updates.
I am planning on bracketing the event code with an
#ifdef ENABLE_EVENTLOG until I finish merging Marcin's
changes (very soon).
(This used to be commit 4e0ac63c36527cd8c52ef720cae17e84f67e7221)
Diffstat (limited to 'source3/lib/time.c')
-rw-r--r-- | source3/lib/time.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/lib/time.c b/source3/lib/time.c index 84004a099b..9f94791b58 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -791,3 +791,25 @@ SMB_BIG_INT usec_time_diff(struct timeval *larget, struct timeval *smallt) SMB_BIG_INT sec_diff = larget->tv_sec - smallt->tv_sec; return (sec_diff * 1000000) + (SMB_BIG_INT)(larget->tv_usec - smallt->tv_usec); } + + +/**************************************************************************** + convert ASN.1 GeneralizedTime string to unix-time + returns 0 on failure; Currently ignores timezone. +****************************************************************************/ +time_t generalized_to_unix_time(const char *str) +{ + struct tm tm; + + ZERO_STRUCT(tm); + + if (sscanf(str, "%4d%2d%2d%2d%2d%2d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { + return 0; + } + tm.tm_year -= 1900; + tm.tm_mon -= 1; + + return timegm(&tm); +} |