libfreerdp-core: fix timezone finding and encoding
This commit is contained in:
parent
af2745a11a
commit
1d93dbab33
@ -106,6 +106,9 @@ boolean rdp_read_client_time_zone(STREAM* s, rdpSettings* settings)
|
||||
|
||||
void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings)
|
||||
{
|
||||
uint32 bias;
|
||||
sint32 sbias;
|
||||
uint32 bias2c;
|
||||
size_t length;
|
||||
uint8* standardName;
|
||||
uint8* daylightName;
|
||||
@ -128,21 +131,40 @@ void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings)
|
||||
if (daylightNameLength > 62)
|
||||
daylightNameLength = 62;
|
||||
|
||||
stream_write_uint32(s, clientTimeZone->bias); /* Bias */
|
||||
/* UTC = LocalTime + Bias <-> Bias = UTC - LocalTime */
|
||||
|
||||
bias = 1440 - clientTimeZone->bias;
|
||||
stream_write_uint32(s, bias); /* Bias */
|
||||
|
||||
/* standardName (64 bytes) */
|
||||
stream_write(s, standardName, standardNameLength);
|
||||
stream_write_zero(s, 64 - standardNameLength);
|
||||
|
||||
rdp_write_system_time(s, &clientTimeZone->standardDate); /* StandardDate */
|
||||
stream_write_uint32(s, clientTimeZone->standardBias); /* StandardBias */
|
||||
|
||||
sbias = clientTimeZone->standardBias - clientTimeZone->bias;
|
||||
|
||||
if (sbias < 0)
|
||||
bias2c = (uint32) sbias;
|
||||
else
|
||||
bias2c = ~((uint32) sbias) + 1;
|
||||
|
||||
stream_write_uint32(s, bias2c); /* StandardBias */
|
||||
|
||||
/* daylightName (64 bytes) */
|
||||
stream_write(s, daylightName, daylightNameLength);
|
||||
stream_write_zero(s, 64 - daylightNameLength);
|
||||
|
||||
rdp_write_system_time(s, &clientTimeZone->daylightDate); /* DaylightDate */
|
||||
stream_write_uint32(s, clientTimeZone->daylightBias); /* DaylightBias */
|
||||
|
||||
sbias = clientTimeZone->daylightBias - clientTimeZone->bias;
|
||||
|
||||
if (sbias < 0)
|
||||
bias2c = (uint32) sbias;
|
||||
else
|
||||
bias2c = ~((uint32) sbias) + 1;
|
||||
|
||||
stream_write_uint32(s, bias2c); /* DaylightBias */
|
||||
|
||||
xfree(standardName);
|
||||
xfree(daylightName);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Time Zone Redirection Table Generator
|
||||
*
|
||||
@ -193,6 +193,7 @@ namespace TimeZones
|
||||
|
||||
foreach (TimeZoneInfo timeZone in timeZones)
|
||||
{
|
||||
Int32 sbias;
|
||||
TIME_ZONE_ENTRY tz;
|
||||
TimeSpan offset = timeZone.BaseUtcOffset;
|
||||
|
||||
@ -201,9 +202,15 @@ namespace TimeZones
|
||||
tz.Id = timeZone.Id;
|
||||
|
||||
if (offset.Hours >= 0)
|
||||
tz.Bias = (UInt32)((offset.Hours * 60) + offset.Minutes);
|
||||
{
|
||||
sbias = (offset.Hours * 60) + offset.Minutes;
|
||||
tz.Bias = (UInt32) sbias;
|
||||
}
|
||||
else
|
||||
tz.Bias = (UInt32)(((-1 * offset.Hours) * 60) + offset.Minutes + 720);
|
||||
{
|
||||
sbias = (offset.Hours * 60) + offset.Minutes;
|
||||
tz.Bias = (UInt32) (1440 + sbias);
|
||||
}
|
||||
|
||||
tz.SupportsDST = timeZone.SupportsDaylightSavingTime;
|
||||
|
||||
@ -225,10 +232,10 @@ namespace TimeZones
|
||||
|
||||
stream.WriteLine("\t{");
|
||||
|
||||
stream.WriteLine("\t\t\"{0}\", {1}, {2}, \"{0}\",",
|
||||
stream.WriteLine("\t\t\"{0}\", {1}, {2}, \"{3}\",",
|
||||
tz.Id, tz.Bias, tz.SupportsDST ? "true" : "false", tz.DisplayName);
|
||||
|
||||
stream.WriteLine("\t\t\"{0}\", \"{0}\",", tz.StandardName, tz.DaylightName);
|
||||
stream.WriteLine("\t\t\"{0}\", \"{1}\",", tz.StandardName, tz.DaylightName);
|
||||
stream.WriteLine("\t\t{0}, {1}", tz.RuleTable, tz.RuleTableCount);
|
||||
|
||||
index++;
|
||||
@ -245,3 +252,4 @@ namespace TimeZones
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user