protected function getDateParameterInTimezone($date, $timezone)
{
$timezoneToUse = null;
// if the requested date is not YYYY-MM-DD, we need to ensure
// it is relative to the website's timezone
if (in_array($date, array('today', 'yesterday'))) {
// today is at midnight; we really want to get the time now, so that
// * if the website is UTC+12 and it is 5PM now in UTC, the calendar will allow to select the UTC "tomorrow"
// * if the website is UTC-12 and it is 5AM now in UTC, the calendar will allow to select the UTC "yesterday"
if ($date == 'today') {
$date = 'now';
} elseif ($date == 'yesterday') {
$date = 'yesterdaySameTime';
}
$timezoneToUse = $timezone;
}
return Date::factory($date, $timezoneToUse);
}