55 void get_offset_utc(
const tm& _tstruct_inp,
int& offset_hours,
int& offset_mins) {
57 const bool LDEBUG = (
false ||
XHOST.DEBUG);
59 tm tstruct_inp = _tstruct_inp;
60 const time_t t_inp = std::mktime(&tstruct_inp);
62 cerr <<
__AFLOW_FUNC__ <<
" ///////////////////////////////////////////////" << endl;
64 cerr <<
__AFLOW_FUNC__ <<
" tstruct_inp.tm_sec=" << tstruct_inp.tm_sec << endl;
65 cerr <<
__AFLOW_FUNC__ <<
" tstruct_inp.tm_min=" << tstruct_inp.tm_min << endl;
66 cerr <<
__AFLOW_FUNC__ <<
" tstruct_inp.tm_hour=" << tstruct_inp.tm_hour << endl;
67 cerr <<
__AFLOW_FUNC__ <<
" tstruct_inp.tm_mday=" << tstruct_inp.tm_mday << endl;
68 cerr <<
__AFLOW_FUNC__ <<
" tstruct_inp.tm_mon=" << tstruct_inp.tm_mon << endl;
69 cerr <<
__AFLOW_FUNC__ <<
" tstruct_inp.tm_year=" << tstruct_inp.tm_year << endl;
70 cerr <<
__AFLOW_FUNC__ <<
" tstruct_inp.tm_wday=" << tstruct_inp.tm_wday << endl;
71 cerr <<
__AFLOW_FUNC__ <<
" tstruct_inp.tm_yday=" << tstruct_inp.tm_yday << endl;
72 cerr <<
__AFLOW_FUNC__ <<
" tstruct_inp.tm_isdst=" << tstruct_inp.tm_isdst << endl;
73 cerr <<
__AFLOW_FUNC__ <<
" mktime(tstruct_inp)=" << t_inp << endl;
74 strftime(buffer, 30,
"%F %T %Z", &tstruct_inp);
76 cerr <<
__AFLOW_FUNC__ <<
" ///////////////////////////////////////////////" << endl;
79 time_t t_local = t_inp;
80 const bool fix_utc_2_now =
false;
82 t_local = time(
nullptr);
84 struct tm* ptr_tstruct_gmt = std::gmtime(&t_local);
86 cerr <<
__AFLOW_FUNC__ <<
" ///////////////////////////////////////////////" << endl;
87 cerr <<
__AFLOW_FUNC__ <<
" LOOKING AT: ptr_tstruct_gmt (BEFORE DST CHANGE)" << endl;
88 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_sec=" << ptr_tstruct_gmt->tm_sec << endl;
89 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_min=" << ptr_tstruct_gmt->tm_min << endl;
90 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_hour=" << ptr_tstruct_gmt->tm_hour << endl;
91 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_mday=" << ptr_tstruct_gmt->tm_mday << endl;
92 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_mon=" << ptr_tstruct_gmt->tm_mon << endl;
93 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_year=" << ptr_tstruct_gmt->tm_year << endl;
94 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_wday=" << ptr_tstruct_gmt->tm_wday << endl;
95 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_yday=" << ptr_tstruct_gmt->tm_yday << endl;
96 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_isdst=" << ptr_tstruct_gmt->tm_isdst << endl;
97 tm tstruct_tmp = *ptr_tstruct_gmt;
98 cerr <<
__AFLOW_FUNC__ <<
" mktime(ptr_tstruct_gmt)=" << std::mktime(&tstruct_tmp) << endl;
99 strftime(buffer, 30,
"%F %T %Z", ptr_tstruct_gmt);
101 cerr <<
__AFLOW_FUNC__ <<
" ///////////////////////////////////////////////" << endl;
104 ptr_tstruct_gmt->tm_isdst = -1;
105 const time_t t_gmt = std::mktime(ptr_tstruct_gmt);
107 cerr <<
__AFLOW_FUNC__ <<
" ///////////////////////////////////////////////" << endl;
108 cerr <<
__AFLOW_FUNC__ <<
" LOOKING AT: ptr_tstruct_gmt (AFTER DST CHANGE)" << endl;
109 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_sec=" << ptr_tstruct_gmt->tm_sec << endl;
110 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_min=" << ptr_tstruct_gmt->tm_min << endl;
111 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_hour=" << ptr_tstruct_gmt->tm_hour << endl;
112 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_mday=" << ptr_tstruct_gmt->tm_mday << endl;
113 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_mon=" << ptr_tstruct_gmt->tm_mon << endl;
114 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_year=" << ptr_tstruct_gmt->tm_year << endl;
115 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_wday=" << ptr_tstruct_gmt->tm_wday << endl;
116 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_yday=" << ptr_tstruct_gmt->tm_yday << endl;
117 cerr <<
__AFLOW_FUNC__ <<
" ptr_tstruct_gmt->tm_isdst=" << ptr_tstruct_gmt->tm_isdst << endl;
118 cerr <<
__AFLOW_FUNC__ <<
" mktime(ptr_tstruct_gmt)=" << t_gmt << endl;
119 strftime(buffer, 30,
"%F %T %Z", ptr_tstruct_gmt);
121 cerr <<
__AFLOW_FUNC__ <<
" ///////////////////////////////////////////////" << endl;
124 const long int t_diff =
static_cast<long int>(t_inp - t_gmt);
128 const double offset = (double) t_diff / 3600.0;
129 offset_hours = (int) std::floor(offset);
130 offset_mins = (int) (std::round((offset - (
double) offset_hours) * 60.0));