Fix windows timezone.

This commit is contained in:
Julien Wadel 2024-03-29 14:38:58 +01:00
parent 3243e0fe73
commit 698e70ebc8
2 changed files with 29 additions and 11 deletions

View file

@ -5,7 +5,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 5.3.0 - undefined
### Added
- Screen Sharing
@ -16,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Call logs synchronization.
- URI handlers when mixing remote provisioning and call.
- Blinking on resize or Ui updates on screen that have low frame rates.
- Timezones and Windows fix.
## 5.2.2 - 2024-03-11

View file

@ -273,19 +273,37 @@ App::App(int &argc, char *argv[])
SLOT(stateChanged(Qt::ApplicationState)));
setWindowIcon(QIcon(Constants::WindowIconPath));
char *tz = getenv("TZ");
if (!tz) { // If not set, set the environement variable for uses of mktime from the SDK.
#ifdef Q_OS_WIN
_putenv(("TZ=" + QTimeZone::systemTimeZoneId().toStdString()).c_str());
_tzset();
char tz[255] = {0};
size_t envSize = 0;
getenv_s(&envSize, tz, 255, "TZ");
if (envSize == 0 || tz[0] == '\0') { // If not set, set the environment variable for uses of mktime from the SDK.
long adjustTimezone;
_tzset(); // init timezone variable
auto error = _get_timezone(&adjustTimezone);
if (adjustTimezone != -QTimeZone::systemTimeZone().offsetFromUtc(QDateTime::currentDateTime())) {
QString timeZone = QTimeZone::systemTimeZoneId();
_putenv(("TZ=" + timeZone.toStdString()).c_str());
_tzset();
qInfo() << "Set TimeZone to " << timeZone;
}
} else qInfo() << "Use environment TimeZone:" << tz;
#else
setenv("TZ", QTimeZone::systemTimeZoneId().toStdString().c_str(), 1);
tzset();
char *tz = getenv("TZ");
if (!tz) { // If not set, set the environment variable for uses of mktime from the SDK.
tzset(); // init timezone variable
if (timezone != -QTimeZone::systemTimeZone().offsetFromUtc(QDateTime::currentDateTime())) {
QString timeZone = QTimeZone::systemTimeZoneId();
setenv("TZ", timeZone.toStdString().c_str(), 1);
tzset();
qInfo() << "Set TimeZone to " << timeZone;
}
} else qInfo() << "Use environment TimeZone:" << tz;
#endif
}
bctbx_set_default_encoding(
Constants::LinphoneLocaleEncoding); // Use UTF-8 for internals. Linphone uses UTF-8 so there will be no loss on
// data with less precise encodings. Qt will do the rest.
// Use UTF-8 for internals. Linphone uses UTF-8 so there will be no loss on
// data with less precise encodings. Qt will do the rest.
bctbx_set_default_encoding(Constants::LinphoneLocaleEncoding);
createParser();
mParser->parse(this->arguments());