Skip to content

Commit

Permalink
Cherry pick branch 'genexuslabs:timezone-header' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiamurialdo authored and genexusbot committed Aug 5, 2023
1 parent ec59725 commit 5556e23
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 33 deletions.
19 changes: 19 additions & 0 deletions dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2319,6 +2319,20 @@ public string GetCookie(string name)
}
return cookieVal;
}
internal string GetUndecodedCookie(string name)
{
string cookieVal = string.Empty;
HttpCookie cookie = TryGetCookie(localCookies, name);
if (cookie == null && _HttpContext != null)
{
cookie = TryGetCookie(_HttpContext.Request.GetCookies(), name);
}
if (cookie != null && cookie.Value != null)
{
cookieVal = cookie.Value;
}
return cookieVal;
}

private HttpCookie TryGetCookie(HttpCookieCollection cookieColl, string name)
{
Expand Down Expand Up @@ -3596,6 +3610,11 @@ internal string ClientTimeZoneId
sTZ = (string)GetCookie(GX_REQUEST_TIMEZONE);
GXLogging.Debug(log, "ClientTimeZone GX_REQUEST_TIMEZONE cookie:", sTZ);
}
if (!DateTimeUtil.ValidTimeZone(sTZ))
{
sTZ = (string)GetUndecodedCookie(GX_REQUEST_TIMEZONE);
GXLogging.Debug(log, "Try reading undecoded ClientTimeZone GX_REQUEST_TIMEZONE cookie:", sTZ);
}
try
{
_currentTimeZoneId = !DateTimeUtil.ValidTimeZone(sTZ) ? DateTimeZoneProviders.Tzdb.GetSystemDefault().Id : sTZ;
Expand Down
33 changes: 0 additions & 33 deletions dotnet/test/DotNetUnitTest/Domain/TimeZoneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,6 @@ public class TimeZoneTest
const string MONTEVIDEO_IANA_TIMEZONE_ID = "America/Montevideo";
const string GUADALAJARA_IANA_TIMEZONE_ID = "America/Mexico_City";
const string PARIS_IANA_TIMEZONE_ID = "Europe/Paris";
[Fact]
public void TimeHeaderValidation()
{
string tz = "Etc/GMT 3";
GxContext ctx = GxContext.CreateDefaultInstance();
ctx.SetTimeZone(tz);
string nodaTimeZone = ctx.GetTimeZone();
string t4znetTimeZone = Context_SetTimeZone_TZ4Net(tz);
Assert.Equal(nodaTimeZone, t4znetTimeZone);

}
#pragma warning disable CS0618 // Type or member is obsolete
string Context_SetTimeZone_TZ4Net(string sTZ)
{
OlsonTimeZone _currentTimeZone;
try
{
_currentTimeZone = TimeZoneUtil.GetInstanceFromOlsonName(sTZ);
}
catch (Exception)
{
try
{
_currentTimeZone = TimeZoneUtil.GetInstanceFromWin32Id(sTZ);
}
catch (Exception)
{
_currentTimeZone = TimeZoneUtil.GetInstanceFromWin32Id(TimeZoneInfo.Local.Id);
}
}
return _currentTimeZone.Name;
}
#pragma warning restore CS0618 // Type or member is obsolete
[Fact]
public void MontevideoTimeZoneConversion_offset3()
{
Expand Down

0 comments on commit 5556e23

Please sign in to comment.