MCPcopy Create free account
hub / github.com/SIPp/sipp / getTimezoneOffset

Function getTimezoneOffset

src/stat.cpp:115–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115static void getTimezoneOffset()
116{
117#ifdef __USE_MISC
118 if (*M_G_gmt_offset) {
119 return;
120 }
121
122 struct tm L_currentDate;
123 // Get the current date and time
124 time_t now = time(NULL);
125 // Convert to local time
126 localtime_r(&now, &L_currentDate);
127
128 long gmtoff = L_currentDate.tm_gmtoff;
129 if (gmtoff == 0) {
130 strcpy(M_G_gmt_offset, "Z");
131 } else {
132 int hh = gmtoff / 3600;
133 int mm = abs(gmtoff / 60) % 60;
134 snprintf(M_G_gmt_offset, sizeof(M_G_gmt_offset), "%+.2d:%.2d", hh, mm);
135 }
136#endif
137}
138
139/*
140 __________________________________________________________________________

Callers 1

initMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected