diff options
Diffstat (limited to 'utils/ltime.c')
-rw-r--r-- | utils/ltime.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/utils/ltime.c b/utils/ltime.c new file mode 100644 index 00000000..75b89535 --- /dev/null +++ b/utils/ltime.c @@ -0,0 +1,16 @@ +/* + * Portable implementation of ltime() for any ISO-C platform where + * time_t behaves. (In practice, we've found that platforms such as + * Windows and Mac have needed their own specialised implementations.) + */ + +#include <time.h> +#include <assert.h> + +struct tm ltime(void) +{ + time_t t; + time(&t); + assert (t != ((time_t)-1)); + return *localtime(&t); +} |