123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #include <netdissect-stdinc.h>
- #include <stdio.h>
- #ifdef HAVE_OS_PROTO_H
- #include "os-proto.h"
- #endif
- #include "gmt2local.h"
- int32_t
- gmt2local(time_t t)
- {
- register int dt, dir;
- register struct tm *gmt, *loc;
- struct tm sgmt;
- if (t == 0)
- t = time(NULL);
- gmt = &sgmt;
- *gmt = *gmtime(&t);
- loc = localtime(&t);
- dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
- (loc->tm_min - gmt->tm_min) * 60;
-
- dir = loc->tm_year - gmt->tm_year;
- if (dir == 0)
- dir = loc->tm_yday - gmt->tm_yday;
- dt += dir * 24 * 60 * 60;
- return (dt);
- }
|