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

Function abbroffset

zic.c:3088–3117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3086 rename_dest(tempname, name);
3087 free(ats);
3088}
3089
3090static char const *
3091abbroffset(char *buf, zic_t offset)
3092{
3093 zic_t offset_lim = 100L * SECSPERHOUR;
3094 if (! (-offset_lim < offset && offset < offset_lim)) {
3095 error(N_("%%z UT offset magnitude exceeds 99:59:59"));
3096 return "%z";
3097 } else {
3098 char sign = offset < 0 ? '-' : '+';
3099 int_fast32_t abs_offset = offset < 0 ? -offset : offset;
3100 int seconds = abs_offset % SECSPERMIN;
3101 int abs_minutes_offset = abs_offset / SECSPERMIN;
3102 int minutes = abs_minutes_offset % MINSPERHOUR;
3103 int hours = abs_minutes_offset / MINSPERHOUR;
3104 char *p = buf;
3105 *p++ = sign;
3106 *p++ = '0' + hours / 10;
3107 *p++ = '0' + hours % 10;
3108 if (minutes | seconds) {
3109 *p++ = '0' + minutes / 10;
3110 *p++ = '0' + minutes % 10;
3111 if (seconds) {
3112 *p++ = '0' + seconds / 10;
3113 *p++ = '0' + seconds % 10;
3114 }
3115 }
3116 *p = '\0';
3117 return buf;
3118 }
3119}
3120

Callers 1

doabbrFunction · 0.85

Calls 1

errorFunction · 0.85

Tested by

no test coverage detected