diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-02-22 17:59:51 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-03-01 02:13:22 +0100 |
commit | 608c8e787253f01b24f95c1523187a0a37737691 (patch) | |
tree | e2af06e52df5d4aee47a8c0efb55f650b6725efe /source3 | |
parent | db11e6505e3205700fe323c550a72df825830f4b (diff) | |
download | samba-608c8e787253f01b24f95c1523187a0a37737691.tar.gz samba-608c8e787253f01b24f95c1523187a0a37737691.tar.bz2 samba-608c8e787253f01b24f95c1523187a0a37737691.zip |
lib/util/time: Merge time functions from source3/lib/time.c
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/time.c | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/source3/lib/time.c b/source3/lib/time.c index eba358f11f..db9ec0a34f 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -129,69 +129,6 @@ int set_server_zone_offset(time_t t) return server_zone_offset; } -/**************************************************************************** - Return the date and time as a string -****************************************************************************/ - -char *timeval_string(TALLOC_CTX *ctx, const struct timeval *tp, bool hires) -{ - fstring TimeBuf; - time_t t; - struct tm *tm; - - t = (time_t)tp->tv_sec; - tm = localtime(&t); - if (!tm) { - if (hires) { - slprintf(TimeBuf, - sizeof(TimeBuf)-1, - "%ld.%06ld seconds since the Epoch", - (long)tp->tv_sec, - (long)tp->tv_usec); - } else { - slprintf(TimeBuf, - sizeof(TimeBuf)-1, - "%ld seconds since the Epoch", - (long)t); - } - } else { -#ifdef HAVE_STRFTIME - if (hires) { - strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %H:%M:%S",tm); - slprintf(TimeBuf+strlen(TimeBuf), - sizeof(TimeBuf)-1 - strlen(TimeBuf), - ".%06ld", - (long)tp->tv_usec); - } else { - strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %H:%M:%S",tm); - } -#else - if (hires) { - const char *asct = asctime(tm); - slprintf(TimeBuf, - sizeof(TimeBuf)-1, - "%s.%06ld", - asct ? asct : "unknown", - (long)tp->tv_usec); - } else { - const char *asct = asctime(tm); - fstrcpy(TimeBuf, asct ? asct : "unknown"); - } -#endif - } - return talloc_strdup(ctx, TimeBuf); -} - -char *current_timestring(TALLOC_CTX *ctx, bool hires) -{ - struct timeval tv; - - GetTimeOfDay(&tv); - return timeval_string(ctx, &tv, hires); -} - - - /*************************************************************************** Server versions of the above functions. ***************************************************************************/ |