Back to index

d-push  2.0
Static Public Member Functions | Static Private Member Functions | Static Private Attributes
TimezoneUtil Class Reference

List of all members.

Static Public Member Functions

static GetFullTZ ($phptimezone=false)
 Returns a full timezone array.
static FillTZNames ($tz)
 Sets the timezone name by matching data from the offset (bias etc)
static TZtest ()
 Test to check if $mstzones and $tzonesoffsets can be resolved in both directions.

Static Private Member Functions

static guessTZNameFromOffset ($offset)
 Tries to find a timezone using the Bias and other offset parameters.
static guessTZNameFromPHPName ($phpname)
 Tries to find a AS timezone for a php timezone.
static getMSTZnameFromTZName ($name)
 Returns an AS compatible tz name.
static encodeTZName ($name)
 Encodes the tz name to UTF-16 compatible with a syncblob.

Static Private Attributes

static $mstzones
 list of MS and AS compatible timezones
static $tzonesoffsets
 Python generated offset list dots in keys were removed.
static $phptimezones
 Generated list of PHP timezones in GMT timezones.

Detailed Description

Definition at line 45 of file timezoneutil.php.


Member Function Documentation

static TimezoneUtil::encodeTZName ( name) [static, private]

Encodes the tz name to UTF-16 compatible with a syncblob.

Parameters:
string$nametimezone name

public

Returns:
string

Definition at line 1231 of file timezoneutil.php.

                                                {
        return substr(iconv('UTF-8', 'UTF-16', $name),2,-1);
    }

Here is the caller graph for this function:

static TimezoneUtil::FillTZNames ( tz) [static]

Sets the timezone name by matching data from the offset (bias etc)

Parameters:
array$offseta z-push timezone array

public

Returns:
array

Definition at line 1140 of file timezoneutil.php.

                                            {
        ZLog::Write(LOGLEVEL_DEBUG, "TimezoneUtil::FillTZNames() filling up bias ". $tz["bias"]);
        if (!isset($tz["bias"]))
            ZLog::Write(LOGLEVEL_WARN, "TimezoneUtil::FillTZNames() submitted TZ array does not have a bias");
        else {
            $tzname = self::guessTZNameFromOffset($tz);
            $tz['tzname'] = $tz['tznamedst'] = self::encodeTZName(self::getMSTZnameFromTZName($tzname));
        }
        return $tz;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static TimezoneUtil::GetFullTZ ( phptimezone = false) [static]

Returns a full timezone array.

Parameters:
string$phptimezone(opt) a php timezone string. If omitted the env. default timezone is used.

public

Returns:
array

Definition at line 1096 of file timezoneutil.php.

                                                           {
        if ($phptimezone === false)
            $phptimezone = date_default_timezone_get();

        ZLog::Write(LOGLEVEL_DEBUG, "TimezoneUtil::GetFullTZ() for ". $phptimezone);

        $servertzname = self::guessTZNameFromPHPName($phptimezone);
        $offset = self::$tzonesoffsets[$servertzname];

        $tz = array(
            "bias" => $offset[0],
            "tzname" => self::encodeTZName(self::getMSTZnameFromTZName($servertzname)),
            "dstendyear" => $offset[3],
            "dstendmonth" => $offset[4],
            "dstendday" => $offset[6],
            "dstendweek" => $offset[5],
            "dstendhour" => $offset[7],
            "dstendminute" => $offset[8],
            "dstendsecond" => $offset[9],
            "dstendmillis" => $offset[10],
            "stdbias" => $offset[1],
            "tznamedst" => self::encodeTZName(self::getMSTZnameFromTZName($servertzname)),
            "dststartyear" => $offset[11],
            "dststartmonth" => $offset[12],
            "dststartday" => $offset[14],
            "dststartweek" => $offset[13],
            "dststarthour" => $offset[15],
            "dststartminute" => $offset[16],
            "dststartsecond" => $offset[17],
            "dststartmillis" => $offset[18],
            "dstbias" => $offset[2]
        );

        return $tz;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static TimezoneUtil::getMSTZnameFromTZName ( name) [static, private]

Returns an AS compatible tz name.

Parameters:
string$nameinternal timezone name

public

Returns:
string

Definition at line 1213 of file timezoneutil.php.

                                                         {
        foreach (self::$mstzones as $mskey => $msdefs) {
            if ($name == $msdefs[0])
                return $msdefs[1];
        }

        ZLog::Write(LOGLEVEL_WARN, sprintf("TimezoneUtil::getMSTZnameFromTZName() no MS name found for '%s'. Returning '(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London'", $name));
        return self::$mstzones["085"][1];
    }

Here is the call graph for this function:

static TimezoneUtil::guessTZNameFromOffset ( offset) [static, private]

Tries to find a timezone using the Bias and other offset parameters.

Parameters:
array$offseta z-push timezone array

public

Returns:
string

Definition at line 1159 of file timezoneutil.php.

                                                           {
        // try to find a quite exact match
        foreach (self::$tzonesoffsets as $tzname => $tzoffset) {
            if ($offset["bias"] == $tzoffset[0] &&
                isset($offset["dstendmonth"])   && $offset["dstendmonth"] == $tzoffset[4] &&
                isset($offset["dstendday"])     && $offset["dstendday"] == $tzoffset[6] &&
                isset($offset["dststartmonth"]) && $offset["dststartmonth"] == $tzoffset[12] &&
                isset($offset["dststartday"])   && $offset["dststartday"] == $tzoffset[14])
                return $tzname;
        }

        // try to find a bias match
        foreach (self::$tzonesoffsets as $tzname => $tzoffset) {
            if ($offset["bias"] == $tzoffset[0])
                return $tzname;
        }

        // nothing found? return gmt
        ZLog::Write(LOGLEVEL_WARN, "TimezoneUtil::guessTZNameFromOffset() no timezone found for the data submitted. Returning 'GMT Standard Time'.");
        return "GMT Standard Time";
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static TimezoneUtil::guessTZNameFromPHPName ( phpname) [static, private]

Tries to find a AS timezone for a php timezone.

Parameters:
string$phpnamea php timezone name

public

Returns:
string

Definition at line 1189 of file timezoneutil.php.

                                                             {
        foreach (self::$phptimezones as $tzn => $phptzs) {
            if (in_array($phpname, $phptzs)) {
                $tzname = $tzn;
                break;
            }
        }

        if (!isset($tzname) || is_int($tzname)) {
            ZLog::Write(LOGLEVEL_ERROR, sprintf("TimezoneUtil::guessTZNameFromPHPName() no compatible timezone found for '%s'. Returning 'GMT Standard Time'. Please contact the Z-Push dev team.", $phpname));
            return self::$mstzones["085"][0];
        }

        return $tzname;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static TimezoneUtil::TZtest ( ) [static]

Test to check if $mstzones and $tzonesoffsets can be resolved in both directions.

public

Returns:

Definition at line 1242 of file timezoneutil.php.

                                    {
        foreach (self::$mstzones as $mskey => $msdefs) {
            if (!array_key_exists($msdefs[0], self::$tzonesoffsets))
                echo "key   '". $msdefs[0]. "'   not found in tzonesoffsets\n";
        }

        foreach (self::$tzonesoffsets as $tzname => $offset) {
            $found = false;
            foreach (self::$mstzones as $mskey => $msdefs) {
                if ($tzname == $msdefs[0]) {
                    $found = true;
                    break;
                }
            }
            if (!$found)
                echo "key    '$tzname' NOT FOUND\n";
        }
    }

Member Data Documentation

TimezoneUtil::$mstzones [static, private]

list of MS and AS compatible timezones

origin: http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx dots of tz identifiers were removed

Updated at: 01.06.2012

Definition at line 55 of file timezoneutil.php.

TimezoneUtil::$phptimezones [static, private]

Generated list of PHP timezones in GMT timezones.

Created at: 01.06.2012

Definition at line 271 of file timezoneutil.php.

TimezoneUtil::$tzonesoffsets [static, private]

Python generated offset list dots in keys were removed.

Array indices 0 = lBias 1 = lStandardBias 2 = lDSTBias 3 = wStartYear 4 = wStartMonth 5 = wStartDOW 6 = wStartDay 7 = wStartHour 8 = wStartMinute 9 = wStartSecond 10 = wStartMilliseconds 11 = wEndYear 12 = wEndMonth 13 = wEndDOW 14 = wEndDay 15 = wEndHour 16 = wEndMinute 17 = wEndSecond 18 = wEndMilloseconds

As the $tzoneoffsets and the $mstzones need to be resolved in both directions, some offsets are commented as they are not available in the $mstzones.

Created at: 01.06.2012

Definition at line 164 of file timezoneutil.php.


The documentation for this class was generated from the following file: