summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/libugly/localtime_r.c
blob: d4bc073ce64c72c80d6fa7c1d7f4bdd4cc32dcbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "dietfeatures.h"
#include <time.h>
#include <sys/time.h>

#ifdef WANT_TZFILE_PARSER
extern void __maplocaltime();
extern time_t __tzfile_map(time_t t, int *isdst);
#endif

struct tm* localtime_r(const time_t* t, struct tm* r) {
  time_t tmp;
#ifdef WANT_TZFILE_PARSER
  __maplocaltime();
  tmp=__tzfile_map(*t,&r->tm_isdst);
#else
  struct timezone tz;
  gettimeofday(0, &tz);
  tmp=*t-tz.tz_minuteswest*60L;
#endif
  return gmtime_r(&tmp,r);
}