for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Class SS_Datetimezone
*
* Adds customisable timezones to the nice method on {@link SS_Datetime}.
*/
class SS_Datetimezone extends SS_Datetime {
You can fix this by adding a namespace to your class:
namespace YourVendor; class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
* Returns the date in the raw SQL-format specific to a given timezone passed from the Member class, e.g. “2006-01-18 16:32:04”
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.
public function Nice() {
//instantiate new DateTime object based off received timestamp in the default timezone
$timestamp = new DateTime($this->value, new DateTimeZone(date_default_timezone_get()));
//if a user is logged in, has set a timezone that is in the allowed list and
//that timezone is NOT the default one then convert the timestamp to use the selected timezone
if(Member::currentUserID() && isset(Member::CurrentUser()->Timezone) && in_array(Member::CurrentUser()->Timezone, timezone_identifiers_list()) && Member::CurrentUser()->Timezone != date_default_timezone_get()){
$timestamp->setTimezone(new DateTimeZone(Member::CurrentUser()->Timezone));
}
//return timestamp in "Nice" format + the user's timezone
return $timestamp->Format('d/m/Y g:ia');
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.