localtime.c 575 B

12345678910111213141516171819202122232425262728293031
  1. #include <time.h>
  2. #include <sys/time.h>
  3. /* These globals are exported by the C library */
  4. char *__tzname[2] = { (char *) "GMT", (char *) "GMT" };
  5. int __daylight = 0;
  6. long int __timezone = 0L;
  7. weak_alias (__tzname, tzname);
  8. weak_alias (__daylight, daylight);
  9. weak_alias (__timezone, timezone);
  10. extern void __tm_conv();
  11. struct tm *localtime(timep)
  12. __const time_t *timep;
  13. {
  14. static struct tm tmb;
  15. struct timezone tz;
  16. time_t offt;
  17. gettimeofday((void *) 0, &tz);
  18. offt = -tz.tz_minuteswest * 60L;
  19. /* tmb.tm_isdst = ? */
  20. __tm_conv(&tmb, timep, offt);
  21. return &tmb;
  22. }