MCPcopy Create free account
hub / github.com/eggert/tz / posix2time_z

Function posix2time_z

localtime.c:3086–3110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3084}
3085
3086NETBSD_INSPIRED_EXTERN time_t
3087posix2time_z(struct state *sp, time_t t)
3088{
3089 int i;
3090 for (i = leapcount(sp); 0 <= --i; ) {
3091 struct lsinfo ls = lsinfo(sp, i);
3092 time_t t_corr = t;
3093
3094 if (increment_overflow_time(&t_corr, ls.ls_corr)) {
3095 if (0 <= ls.ls_corr) {
3096 /* Overflow near maximum time_t value with positive correction.
3097 This can happen with ordinary TZif files with leap seconds. */
3098 errno = EOVERFLOW;
3099 return -1;
3100 } else {
3101 /* A negative correction overflowed, so keep going.
3102 This can happen with unrealistic-but-valid TZif files. */
3103 }
3104 } else if (ls.ls_trans <= t_corr)
3105 return (t_corr
3106 - (ls.ls_trans == t_corr
3107 && (i == 0 ? 0 : lsinfo(sp, i - 1).ls_corr) < ls.ls_corr));
3108 }
3109 return t;
3110}
3111
3112time_t
3113posix2time(time_t t)

Callers 1

posix2timeFunction · 0.85

Calls 3

leapcountFunction · 0.85
increment_overflow_timeFunction · 0.85
lsinfoClass · 0.70

Tested by

no test coverage detected