Let's say we want to create new Date instance with custom timezone:
$date = Date::factory('2016-01-26', 'America/New_York');
In this factory it is assumed that input date is always in UTC, so I would expect following behavior:
Let's create new Range period instance:
$period = new Range('day', '2016-01-26,2016-01-27', 'America/New_York');
This is how this period behaves:
That looks like a bug indeed and it could cause problems as it seems to be used around Archiving etc. In this line https://github.com/piwik/piwik/blob/2.16.0/core/Date.php#L190 it applies the timezone so it doesn't return the start of the day in UTC but in the given timezone.
The description of the method says:
Returns the start of the day of the current timestamp in UTC.
but it looks like it definitely doesn't. However, I wonder, if maybe only the name of the method and the description is wrong so far and the behaviour is maybe expected? Really surprised that the timezone is applied there when it specifically says UTC. @mattab any ideas?
We should make
Period\Factory public API and remove API from
__constructor maybe to force creation of Periods via the factory? Not sure!