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

Function _yconv

strftime.c:686–712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684*/
685
686static char *
687_yconv(int a, int b, bool convert_top, bool convert_yy,
688 char *pt, const char *ptlim)
689{
690 register int lead;
691 register int trail;
692
693 int DIVISOR = 100;
694 trail = a % DIVISOR + b % DIVISOR;
695 lead = a / DIVISOR + b / DIVISOR + trail / DIVISOR;
696 trail %= DIVISOR;
697 if (trail < 0 && lead > 0) {
698 trail += DIVISOR;
699 --lead;
700 } else if (lead < 0 && trail > 0) {
701 trail -= DIVISOR;
702 ++lead;
703 }
704 if (convert_top) {
705 if (lead == 0 && trail < 0)
706 pt = _add("-0", pt, ptlim);
707 else pt = _conv(lead, "%02d", pt, ptlim);
708 }
709 if (convert_yy)
710 pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim);
711 return pt;
712}

Callers 1

_fmtFunction · 0.85

Calls 2

_addFunction · 0.85
_convFunction · 0.85

Tested by

no test coverage detected