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

Function stringoffset

zic.c:3168–3197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3166 if (max_year < x)
3167 max_year = x;
3168}
3169
3170static int
3171stringoffset(char *result, zic_t offset)
3172{
3173 register int hours;
3174 register int minutes;
3175 register int seconds;
3176 bool negative = offset < 0;
3177 int len = negative;
3178
3179 if (negative) {
3180 offset = -offset;
3181 result[0] = '-';
3182 }
3183 seconds = offset % SECSPERMIN;
3184 offset /= SECSPERMIN;
3185 minutes = offset % MINSPERHOUR;
3186 offset /= MINSPERHOUR;
3187 if (offset >= HOURSPERDAY * DAYSPERWEEK) {
3188 result[0] = '\0';
3189 return 0;
3190 }
3191 hours = offset;
3192 len += sprintf(result + len, "%d", hours);
3193 if (minutes != 0 || seconds != 0) {
3194 len += sprintf(result + len, ":%02d", minutes);
3195 if (seconds != 0)
3196 len += sprintf(result + len, ":%02d", seconds);
3197 }
3198 return len;
3199}
3200

Callers 2

stringruleFunction · 0.85
stringzoneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected