Posts

Showing posts from March, 2019

Calculating Daylight saving and UTC offset in QT

void getTimeZoneOffset() {     QString UTC_offset;     time_t current_time;     time(&current_time);     QString Daylighsaving ;     struct tm *timeinfo = localtime(&current_time);     double offset = (timeinfo->tm_gmtoff)/60;     if (timeinfo->tm_isdst)     {         offset += 60;         Daylighsaving = "1";     }     if (offset > 0)     {         offset = -offset;     }     else{         offset = -(offset);     }     UTC_offset = QString::number(offset); }