| 194 | |
| 195 | #ifdef FSTACK |
| 196 | int32_t |
| 197 | gmt2local(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 | |
| 225 | int |