1/* u_localtime.c 2 * 3 * Copyright (c) 1996-2005 Mike Gleason, NcFTP Software. 4 * All rights reserved. 5 * 6 */ 7 8#include "syshdrs.h" 9#ifdef PRAGMA_HDRSTOP 10# pragma hdrstop 11#endif 12 13#define _CRT_SECURE_NO_WARNINGS 1 14 15struct tm * 16Localtime(time_t t, struct tm *const tp) 17{ 18#if defined(HAVE_LOCALTIME_R) && (defined(HPUX)) && (HPUX < 1100) 19 if (t == 0) 20 time(&t); 21 if (localtime_r(&t, tp) == 0) 22 return (tp); 23#elif defined(HAVE_LOCALTIME_R) && !defined(MACOSX) 24 if (t == 0) 25 time(&t); 26 if (localtime_r(&t, tp) != NULL) 27 return (tp); 28#else 29 struct tm *tmp; 30 31 if (t == 0) 32 time(&t); 33 tmp = localtime(&t); 34 if (tmp != NULL) { 35 memcpy(tp, tmp, sizeof(struct tm)); 36 return (tp); 37 } 38#endif 39 memset(tp, 0, sizeof(struct tm)); 40 return NULL; 41} /* Localtime */ 42