| 3084 | } |
| 3085 | |
| 3086 | NETBSD_INSPIRED_EXTERN time_t |
| 3087 | posix2time_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 | |
| 3112 | time_t |
| 3113 | posix2time(time_t t) |
no test coverage detected