zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
U
«ý°d‡2ã@sðdZddlZddlZddlmZddlmZzddlZddlmZWne    k
r`e
dƒ‚YnXddl m Z d    d
d gZ e d ¡Zd ZdZdZdd„ZeƒZGdd „d eƒZGdd„de ƒZGdd    „d    eƒZGdd
„d
eƒZdd„Zdd„ZdS)zä
This module provides an interface to the native time zone data on Windows,
including :py:class:`datetime.tzinfo` implementations.
 
Attempting to import this module on a non-Windows platform will raise an
:py:obj:`ImportError`.
éN)Úwinreg)Ú    text_type)Úwintypesz#Running tzwin on non-Windows systemé)Ú tzrangebaseÚtzwinÚ
tzwinlocalÚtzreséz7SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zonesz4SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zonesz4SYSTEM\CurrentControlSet\Control\TimeZoneInformationcCsLt dtj¡}zt |t¡ ¡t}Wntk
r>t}YnX| ¡|S©N)rÚConnectRegistryÚHKEY_LOCAL_MACHINEÚOpenKeyÚ TZKEYNAMENTÚCloseÚ WindowsErrorÚ TZKEYNAME9X)ÚhandleÚ    TZKEYNAME©rúFd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\dateutil/tz/win.pyÚ _settzkeyname"s
rc@s6eZdZdZe ej¡Zd
dd„Z    dd„Z
dd„Z d    S) r    z}
    Class for accessing ``tzres.dll``, which contains timezone name related
    resources.
 
    .. versionadded:: 2.5.0
    ú    tzres.dllcCs@t d¡}tjtjtjtjf|j_|j|_t |¡|_    ||_
dS)NÚuser32) ÚctypesÚWinDLLrÚ    HINSTANCEÚUINTÚLPWSTRÚc_intÚ LoadStringWÚargtypesÚ_tzresÚ    tzres_loc)Úselfr#rrrrÚ__init__9s
ý ztzres.__init__cCs<| ¡}t t |¡tj¡}| |jj||d¡}|d|…S)aÜ
        Load a timezone name from a DLL offset (integer).
 
        >>> from dateutil.tzwin import tzres
        >>> tzr = tzres()
        >>> print(tzr.load_name(112))
        'Eastern Standard Time'
 
        :param offset:
            A positive integer value referring to a string from the tzres dll.
 
        .. note::
 
            Offsets found in the registry are generally of the form
            ``@tzres.dll,-114``. The offset in this case is 114, not -114.
 
        rN)    Úp_wcharrÚcastÚbyrefrrr r"Ú_handle)r$ÚoffsetÚresourceZlpBufferZncharrrrÚ    load_nameGsztzres.load_namecCsH| d¡s|S| d¡}zt|dƒ}Wntdƒ‚YnX| |¡S)aŸ
        Parse strings as returned from the Windows registry into the time zone
        name as defined in the registry.
 
        >>> from dateutil.tzwin import tzres
        >>> tzr = tzres()
        >>> print(tzr.name_from_string('@tzres.dll,-251'))
        'Dateline Daylight Time'
        >>> print(tzr.name_from_string('Eastern Standard Time'))
        'Eastern Standard Time'
 
        :param tzname_str:
            A timezone name string as returned from a Windows registry key.
 
        :return:
            Returns the localized timezone string from tzres.dll if the string
            is of the form `@tzres.dll,-offset`, else returns the input string.
        ú@z,-rzMalformed timezone string.)Ú
startswithÚsplitÚintÚ
ValueErrorr,)r$Z
tzname_strZ    name_spltr*rrrÚname_from_string^s
 
ztzres.name_from_stringN)r) Ú__name__Ú
__module__Ú __qualname__Ú__doc__rÚPOINTERrÚWCHARr&r%r,r2rrrrr    0s
 
c@sPeZdZdZdd„Zdd„Zedd„ƒZdd    „Zd
d „Z    d d „Z
e dd„ƒZ dS)Ú    tzwinbasezBtzinfo class based on win32's timezones available in the registry.cCs tdƒ‚dS)Nz#tzwinbase is an abstract base class)ÚNotImplementedError©r$rrrr%sztzwinbase.__init__cCsžt|tƒstS|j|jkoœ|j|jkoœ|j|jkoœ|j|jkoœ|j|jkoœ|j|jkoœ|j    |j    koœ|j
|j
koœ|j |j koœ|j |j koœ|j |j koœ|j|jkSr )Ú
isinstancer9ÚNotImplementedÚ _std_offsetÚ _dst_offsetÚ _stddayofweekÚ _dstdayofweekÚ_stdweeknumberÚ_dstweeknumberÚ_stdhourÚ_dsthourÚ
_stdminuteÚ
_dstminuteÚ    _std_abbrÚ    _dst_abbr)r$ÚotherrrrÚ__eq__‚s2
 
ÿ
þ
ý
ü
û
ú
ù
ø    
÷
 
ö
õztzwinbase.__eq__c
sVt dtj¡>}t |t¡&‰‡fdd„tt ˆ¡dƒDƒ}W5QRXW5QRX|S)z4Return a list of all time zones known to the system.Ncsg|]}t ˆ|¡‘qSr)rÚEnumKey)Ú.0Úi©ÚtzkeyrrÚ
<listcomp>™sÿz"tzwinbase.list.<locals>.<listcomp>r)rr r rrÚrangeÚ QueryInfoKey)rÚresultrrOrÚlist”s 
ÿztzwinbase.listcCs|jS)z;
        Return the display name of the time zone.
        )Ú_displayr;rrrÚdisplaysztzwinbase.displaycCsT|js
dSt||j|j|j|j|jƒ}t||j|j|j    |j
|j ƒ}||j 8}||fS)aô
        For a given year, get the DST on and off transition times, expressed
        always on the standard time side. For zones with no transitions, this
        function returns ``None``.
 
        :param year:
            The year whose transitions you would like to query.
 
        :return:
            Returns a :class:`tuple` of :class:`datetime.datetime` objects,
            ``(dston, dstoff)`` for zones with an annual DST transition, or
            ``None`` for fixed offset zones.
        N) ÚhasdstÚpicknthweekdayÚ    _dstmonthrArErGrCÚ    _stdmonthr@rDrFrBÚ_dst_base_offset)r$ÚyearZdstonZdstoffrrrÚ transitions£s þ þ
ztzwinbase.transitionscCs
|jdkS)Nr)rZr;rrrÚ _get_hasdstÂsztzwinbase._get_hasdstcCs|jSr )Ú_dst_base_offset_r;rrrr\Åsztzwinbase._dst_base_offsetN) r3r4r5r6r%rKÚ staticmethodrUrWr^r_Úpropertyr\rrrrr9}s
r9c@s(eZdZdZdd„Zdd„Zdd„ZdS)    ra»
    Time zone object created from the zone info in the Windows registry
 
    These are similar to :py:class:`dateutil.tz.tzrange` objects in that
    the time zone data is provided in the format of a single offset rule
    for either 0 or 2 time zone transitions per year.
 
    :param: name
        The name of a Windows time zone key, e.g. "Eastern Standard Time".
        The full list of keys can be retrieved with :func:`tzwin.list`.
    c    
Cs||_t dtj¡8}tdƒjt|d}t ||¡}t|ƒ}W5QRXW5QRX|d|_    |d|_
|d|_ t   d|d¡}|d |d    }||d
}tj|d |_tj|d |_|d d …\|_|_|_|_|_|dd…\|_|_|_|_|_|j|j|_| ¡|_dS)Nz {kn}\{name})ÚknÚnameZStdZDltÚDisplayz=3l16hZTZIrré©Úminuteséé    é é)Ú_namerr r rÚformatrrÚ valuestodictrHrIrVÚstructÚunpackÚdatetimeÚ    timedeltar>r?r[r@rBrDrFrZrArCrErGr`r_rX)    r$rdrÚ    tzkeynamerPÚkeydictÚtupÚ    stdoffsetÚ    dstoffsetrrrr%×s6
 
 
 
ü
üztzwin.__init__cCsdt|jƒS)Nz    tzwin(%s))Úreprrmr;rrrÚ__repr__üsztzwin.__repr__cCs|j|jffSr )Ú    __class__rmr;rrrÚ
__reduce__ÿsztzwin.__reduce__N)r3r4r5r6r%rzr|rrrrrÊs %c@s0eZdZdZdd„Zdd„Zdd„Zdd    „Zd
S) ra,
    Class representing the local time zone information in the Windows registry
 
    While :class:`dateutil.tz.tzlocal` makes system calls (via the :mod:`time`
    module) to retrieve time zone information, ``tzwinlocal`` retrieves the
    rules directly from the Windows registry and creates an object like
    :class:`dateutil.tz.tzwin`.
 
    Because Windows does not have an equivalent of :func:`time.tzset`, on
    Windows, :class:`dateutil.tz.tzlocal` instances will always reflect the
    time zone settings *at the time that the process was started*, meaning
    changes to the machine's time zone settings during the run of a program
    on Windows will **not** be reflected by :class:`dateutil.tz.tzlocal`.
    Because ``tzwinlocal`` reads the registry directly, it is unaffected by
    this issue.
    c
 
Csnt dtj¡˜}t |t¡}t|ƒ}W5QRX|d|_|d|_zBtdƒj    t
|jd}t ||¡}t|ƒ}|d|_ W5QRXWnt k
r d|_ YnXW5QRX|d |d}||d}t j|d    |_t j|d    |_t d
|d ¡}    |    d d …\|_|_|_|_|    d|_t d
|d¡}    |    d d …\|_|_|_|_|    d|_|j|j|_| ¡|_dS)NZ StandardNameZ DaylightNamez    {kn}\{sn})rcZsnreZBiasZ StandardBiasZ DaylightBiasrgz=8hZ StandardStartrér
Z DaylightStart) rr r rÚTZLOCALKEYNAMErorHrIrrnrrVÚOSErrorrrrsr>r?rprqr[rBrDrFr@rZrCrErGrAr`r_rX)
r$rZ
tzlocalkeyrurtrPZ_keydictrwrxrvrrrr%sD
 
 
ÿ 
ý
 
ý
ztzwinlocal.__init__cCsdS)Nz tzwinlocal()rr;rrrrzBsztzwinlocal.__repr__cCsdt|jƒS)Nztzwinlocal(%s))ryrHr;rrrÚ__str__Esztzwinlocal.__str__cCs
|jdfS)Nr)r{r;rrrr|Isztzwinlocal.__reduce__N)r3r4r5r6r%rzr€r|rrrrrs
.c    CsTt ||d||¡}|j|| ¡ddd}||dt}|j|krP|t8}|S)z> dayofweek == 0 means Sunday, whichweek 5 means last instance rr
)Úday)rrÚreplaceÚ
isoweekdayÚONEWEEKÚmonth)    r]r…Z    dayofweekÚhourÚminuteZ    whichweekÚfirstZ
weekdayoneÚwdrrrrYMs 
rYcCsši}t |¡d}d}t|ƒD]v}t ||¡\}}}|tjksH|tjkrZ|d@rŒ|d}n2|tjkrŒ| d¡r‚|pvtƒ}|     |¡}| 
d¡}|||<q|S)z0Convert a registry key's values to a dictionary.rNllz@tzresú) rrSrRÚ    EnumValueÚ    REG_DWORDÚREG_DWORD_LITTLE_ENDIANÚREG_SZr.r    r2Úrstrip)ÚkeyZdoutÚsizeZtz_resrNZkey_nameÚvalueZdtyperrrro[s 
 
 
 
 
 
 
ro)r6rrrpZ    six.movesrÚsixrrrr1Ú ImportErrorZ_commonrÚ__all__rsr„rrr~rrÚobjectr    r9rrrYrorrrrÚ<module>s.   
 
 MM9J