MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gmt2local

Function gmt2local

tools/ndp/ndp.c:196–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194
195#ifdef FSTACK
196int32_t
197gmt2local(time_t t)
198{
199 register int dt, dir;
200 register struct tm *gmt, *loc;
201 struct tm sgmt;
202
203 if (t == 0)
204 t = time(NULL);
205 gmt = &sgmt;
206 *gmt = *gmtime(&t);
207 loc = localtime(&t);
208 dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
209 (loc->tm_min - gmt->tm_min) * 60;
210
211 /*
212 * If the year or julian day is different, we span 00:00 GMT
213 * and must add or subtract a day. Check the year first to
214 * avoid problems when the julian day wraps.
215 */
216 dir = loc->tm_year - gmt->tm_year;
217 if (dir == 0)
218 dir = loc->tm_yday - gmt->tm_yday;
219 dt += dir * 24 * 60 * 60;
220
221 return (dt);
222}
223#endif
224
225int

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected