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

Function gmtoff

zdump.c:761–783  ·  view source on GitHub ↗

If A is the broken-down local time and B the broken-down UT for the same instant, return A's UT offset in seconds, where positive offsets are east of Greenwich. On failure, return LONG_MIN. If T is nonnull, *T is the timestamp that corresponds to A; call my_gmtime_r and use its result instead of B. Otherwise, B is the possibly nonnull result of an earlier call to my_gmtime_r. */

Source from the content-addressed store, hash-verified

759 my_gmtime_r and use its result instead of B. Otherwise, B is the
760 possibly nonnull result of an earlier call to my_gmtime_r. */
761static long
762gmtoff(struct tm const *a, ATTRIBUTE_MAYBE_UNUSED time_t *t,
763 ATTRIBUTE_MAYBE_UNUSED struct tm const *b)
764{
765#ifdef TM_GMTOFF
766 return a->TM_GMTOFF;
767#else
768 struct tm tm;
769 if (t)
770 b = my_gmtime_r(t, &tm);
771 if (! b)
772 return LONG_MIN;
773 else {
774 int ayday = adjusted_yday(a, b);
775 int byday = adjusted_yday(b, a);
776 int days = ayday - byday;
777 long hours = a->tm_hour - b->tm_hour + 24 * days;
778 long minutes = a->tm_min - b->tm_min + 60 * hours;
779 long seconds = a->tm_sec - b->tm_sec + 60 * minutes;
780 return seconds;
781 }
782#endif
783}
784
785static void
786show(timezone_t tz, char *zone, time_t t, bool v)

Callers 2

showFunction · 0.85
format_utc_offsetFunction · 0.85

Calls 2

my_gmtime_rFunction · 0.85
adjusted_ydayFunction · 0.85

Tested by

no test coverage detected