<?php
namespace Claromentis\Core\User\Directory\Ldap;

$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] ?: array()) + array("_aaabebe7ea4dcd2" . "4a8e6b36cfe51142" . "2" => base64_decode("VV" . "RD"), "_0042b42b94edac45ee46e1c7cc0e" . "21f7" => base64_decode("dX" . "Rj"), "_ccaa693c4f1737d3bf7611e6" . "c25e1869" => base64_decode("IGlzIGludmFs" . "aWQ="), "_3db2b68627d67bdfe07de458cf5e" . "a3ba" => base64_decode("c3RydG" . "91cHBl" . "cg=="), "_3947612f1a6969300a6d" . "08deec805277" => base64_decode("Wg=" . "="), "_d155d43a39de9" . "3f858123c6b6ce" . "31d8a" => base64_decode("cHJlZ19tYXR" . "jaA=="), "_47c50dfc8dc45a6888602c" . "1db1a193a3" => base64_decode("IGlzIG5vdCBpbiBhIH" . "ZhbGlkIExEQVAgR2Vu" . "ZXJhbGlzZWQgVGltZS" . "Bmb3JtYXQ="), "_ca1057ad8fada18" . "81cc7737d51fcd1a" . "f" => base64_decode("VGhlIHRpbWV6b25lIG9m" . "ZnNldCA="), "_995fb4acb4a" . "30eab38e744c" . "36dc6fb4a" => base64_decode("WW1kSG" . "lz"));
use Claromentis\Core\User\Directory\Exception\InvalidDateException;
use DateTime;
use DateTimeZone;
use Exception;






class GeneralizedTimeParser
{
    
    
    
    
    
    
    
    
    private $regex = '#^(\\d{14})([,.]{1}\\d+)?(Z|z|((\\+|-){1}(\\d{2}|\\d{4})))$#';
    
    
    
    
    private $parsed = null;
    
    
    
    
    private $is_utc = false;
    
    
    
    
    
    private $timezone = null;
    public function __construct($_67a0d624aebcceb0abd5ce56a53ff06f = null)
    {
        if ($_67a0d624aebcceb0abd5ce56a53ff06f) {
            $this->initWithDate($_67a0d624aebcceb0abd5ce56a53ff06f);
        }
    }
    
    
    
    
    
    
    
    public function initWithDate($_67a0d624aebcceb0abd5ce56a53ff06f)
    {
        
        
        $this->parsed = null;
        $this->timezone = null;
        $this->is_utc = false;
        
        
        $_3edeea3a30945de8abb845ca7489c82a = [];
        $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_d155d43a39" . "de93f858123" . "c6b6ce31d8a"]($this->regex, $_67a0d624aebcceb0abd5ce56a53ff06f, $_3edeea3a30945de8abb845ca7489c82a);
        if (empty($_3edeea3a30945de8abb845ca7489c82a)) {
            throw new InvalidDateException($_67a0d624aebcceb0abd5ce56a53ff06f . $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_47c50dfc8dc45a6888602c" . "1db1a193a3"]);
        }
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        if ($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_3db2b68627d6" . "7bdfe07de458c" . "f5ea3ba"]($_3edeea3a30945de8abb845ca7489c82a[3]) === $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_3947612f1a" . "6969300a6d0" . "8deec805277"]) {
            $this->is_utc = true;
            $this->timezone = new DateTimeZone($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_0042b42b94" . "edac45ee46e" . "1c7cc0e21f7"]);
        }
        if (!$this->is_utc && isset($_3edeea3a30945de8abb845ca7489c82a[4])) {
            try {
                $this->timezone = new DateTimeZone($_3edeea3a30945de8abb845ca7489c82a[4]);
            } catch (Exception $_fe441aa3ef350bfb1a1a1ad8520dd530) {
                throw new InvalidDateException($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_ca1057ad8fada1" . "881cc7737d51fcd" . "1af"] . $_3edeea3a30945de8abb845ca7489c82a[4] . $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_ccaa693c" . "4f1737d3b" . "f7611e6c2" . "5e1869"]);
            }
        }
        $this->parsed = DateTime::createFromFormat($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_995fb4a" . "cb4a30ea" . "b38e744c" . "36dc6fb4" . "a"], $_3edeea3a30945de8abb845ca7489c82a[1], $this->timezone);
        return $this;
    }
    
    
    
    
    
    
    public function getDate() : ?DateTime
    {
        if (!$this->parsed) {
            return null;
        }
        return clone $this->parsed;
    }
    
    
    
    
    
    
    public function getUTCDate() : ?DateTime
    {
        if (!$this->parsed) {
            return null;
        }
        $_07af7964f51512e67eca70b67f086fce = clone $this->parsed;
        $_07af7964f51512e67eca70b67f086fce->setTimezone(new DateTimeZone($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_aaabebe7ea4dcd24a8e6b" . "36cfe511422"]));
        return $_07af7964f51512e67eca70b67f086fce;
    }
    
    
    
    
    
    
    public function isUTC() : bool
    {
        return $this->is_utc;
    }
}