Skip to content

Commit

Permalink
fix: send forced datetime value (&cdt parameter) in UTC as specified in
Browse files Browse the repository at this point in the history
  • Loading branch information
julienmoumne committed Apr 20, 2017
1 parent 6fe5602 commit eaa79ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
18 changes: 2 additions & 16 deletions Piwik.Tracker.Tests/PiwikTrackerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,23 +446,9 @@ public void SetEcommerceView_Test(string sku, string name, string categories, do
[TestCase(false)]
public void SetForceVisitDateTime_WhenSpecified_IsAddedToRequest(bool setValue)
{
// Arrange
var expected = DateTime.Now;
//Act
if (setValue)
{
_sut.SetForceVisitDateTime(expected);
}
// Assert
var actual = _sut.GetRequest(SiteId);
if (setValue)
{
Assert.That(actual, Does.Contain("&cdt=" + expected.ToString("yyyy-MM-dd HH:mm:ss")));
}
else
{
Assert.That(actual, Does.Not.Contain("&cdt"));
}
_sut.SetForceVisitDateTime(new DateTimeOffset(2017, 4, 20, 18, 11, 10, new TimeSpan(2, 0, 0)));
Assert.That(_sut.GetRequest(SiteId), setValue ? Does.Contain("&cdt=2017-04-20 16:11:10") : Does.Not.Contain("&cdt"));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion Piwik.Tracker/PiwikTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ protected Dictionary<string, string[]> GetCustomVariablesFromCookie()

private string FormatDateValue(DateTimeOffset date)
{
return date.ToString("yyyy-MM-dd HH:mm:ss");
return date.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
}

private string FormatTimestamp(DateTimeOffset date)
Expand Down

0 comments on commit eaa79ea

Please sign in to comment.