MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / date_strget

Function date_strget

src/misc.c:2860–2895  ·  view source on GitHub ↗

---End cut here--- @cond Doxygen_Suppress

Source from the content-addressed store, hash-verified

2858//---End cut here---
2859//! @cond Doxygen_Suppress
2860char *date_strget(char *buf, int buflen, int localtime)
2861{
2862 char tmpbuf[64];
2863 struct tm *mytm;
2864 time_t t;
2865 struct timeval tv;
2866 struct tm result = { 0, 0, 0, 0, 0, 0, 0, 0, 0};
2867 int mytimezone;
2868
2869 // 2038 failure here for 32-bit time_t
2870 t = time(NULL);
2871
2872 if (localtime)
2873 {
2874 mytm = localtime_r(&t, &result);
2875#if defined(_WIN32)
2876 mytimezone = timezone;
2877#else
2878 mytimezone = - (int)result.tm_gmtoff; // does not compile on mingw
2879#endif
2880 }
2881 else
2882 {
2883 mytm = gmtime_r(&t, &result);
2884 mytimezone = 0;
2885 }
2886
2887 strftime(buf, buflen, "%Y-%m-%dT%H:%M:%S.", mytm);
2888 gettimeofday(&tv, NULL);
2889 SNPRINTF(tmpbuf, sizeof(tmpbuf), "%06ld", (long)tv.tv_usec);
2890 strcat(buf, tmpbuf);
2891 SNPRINTF(tmpbuf, sizeof(tmpbuf), "%s%04d", mytimezone >= 0 ? "-" : "+",
2892 ((int)abs(mytimezone) / 3600) * 100);
2893 strcat(buf, tmpbuf);
2894 return buf;
2895}
2896
2897char *rig_date_strget(char *buf, int buflen, int localtime)
2898{

Callers 13

frameGetFunction · 0.85
frameGetFunction · 0.85
frameGetFunction · 0.85
frameGetFunction · 0.85
frameGetFunction · 0.85
frameGetFunction · 0.85
rig_cookieFunction · 0.85
mainFunction · 0.85
json_add_timeFunction · 0.85
rig_debugFunction · 0.85
rig_date_strgetFunction · 0.85
snapshot_serializeFunction · 0.85

Calls 2

gettimeofdayFunction · 0.85
gmtime_rFunction · 0.70

Tested by

no test coverage detected