MCPcopy Create free account
hub / github.com/dateutil/dateutil / _tzparser

Class _tzparser

src/dateutil/parser/_parser.py:1365–1573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1363
1364
1365class _tzparser:
1366
1367 class _result(_resultbase):
1368
1369 __slots__ = ["stdabbr", "stdoffset", "dstabbr", "dstoffset",
1370 "start", "end"]
1371
1372 class _attr(_resultbase):
1373 __slots__ = ["month", "week", "weekday",
1374 "yday", "jyday", "day", "time"]
1375
1376 def __repr__(self):
1377 return self._repr("")
1378
1379 def __init__(self):
1380 _resultbase.__init__(self)
1381 self.start = self._attr()
1382 self.end = self._attr()
1383
1384 def parse(self, tzstr):
1385 res = self._result()
1386 l = [x for x in re.split(r'([,:.]|[a-zA-Z]+|[0-9]+)',tzstr) if x]
1387 used_idxs = list()
1388 try:
1389
1390 len_l = len(l)
1391
1392 i = 0
1393 while i < len_l:
1394 # BRST+3[BRDT[+2]]
1395 j = i
1396 while j < len_l and not [x for x in l[j]
1397 if x in "0123456789:,-+"]:
1398 j += 1
1399 if j != i:
1400 if not res.stdabbr:
1401 offattr = "stdoffset"
1402 res.stdabbr = "".join(l[i:j])
1403 else:
1404 offattr = "dstoffset"
1405 res.dstabbr = "".join(l[i:j])
1406
1407 for ii in range(j):
1408 used_idxs.append(ii)
1409 i = j
1410 if (i < len_l and (l[i] in ('+', '-') or l[i][0] in
1411 "0123456789")):
1412 if l[i] in ('+', '-'):
1413 # Yes, that's right. See the TZ variable
1414 # documentation.
1415 signal = (1, -1)[l[i] == '+']
1416 used_idxs.append(i)
1417 i += 1
1418 else:
1419 signal = -1
1420 len_li = len(l[i])
1421 if len_li == 4:
1422 # -0300

Callers 3

_parser.pyFile · 0.85

Calls

no outgoing calls

Tested by 2