|
Message-ID: <52A0404A.4050106@skarnet.org> Date: Thu, 05 Dec 2013 08:58:50 +0000 From: Laurent Bercot <ska-dietlibc@...rnet.org> To: musl@...ts.openwall.com Subject: Re: [PATCHv2] Add support for leap seconds in zoneinfo files > i assume > > hit=leapsecs_sub(&t); > if(hit) t++; > leapsecs_add(&t,hit); This is true if and only if all leap seconds are 1, which is the case for now and in the foreseeable future, but my version supports even the improbable case where different corrections are introduced. But you are right, it is possible to go backwards too: static void leapsecs_add(long long *t, int hit) { long long trans; int corr; unsigned int i = __leapsecs_num; for (; i; i--) { __leapsecs_read(i-1, &trans, &corr); if (*t + corr >= trans) break ; } if (i) { *t += corr; if (hit && (t == trans)) { int oldcorr = 0; if (i > 1) __leapsecs_read(i-2, &trans, &oldcorr); *t += oldcorr - corr; } } } -- Laurent
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.