MCPcopy Index your code
hub / github.com/clips/pattern / _parse_date_w3dtf

Function _parse_date_w3dtf

pattern/web/feed/feedparser.py:3355–3448  ·  view source on GitHub ↗
(dateString)

Source from the content-addressed store, hash-verified

3353# http://msdn.microsoft.com/en-us/library/ms186724.aspx
3354# (which basically means allowing a space as a date/time/timezone separator)
3355def _parse_date_w3dtf(dateString):
3356 def __extract_date(m):
3357 year = int(m.group('year'))
3358 if year < 100:
3359 year = 100 * int(time.gmtime()[0] / 100) + int(year)
3360 if year < 1000:
3361 return 0, 0, 0
3362 julian = m.group('julian')
3363 if julian:
3364 julian = int(julian)
3365 month = julian / 30 + 1
3366 day = julian % 30 + 1
3367 jday = None
3368 while jday != julian:
3369 t = time.mktime((year, month, day, 0, 0, 0, 0, 0, 0))
3370 jday = time.gmtime(t)[-2]
3371 diff = abs(jday - julian)
3372 if jday > julian:
3373 if diff < day:
3374 day = day - diff
3375 else:
3376 month = month - 1
3377 day = 31
3378 elif jday < julian:
3379 if day + diff < 28:
3380 day = day + diff
3381 else:
3382 month = month + 1
3383 return year, month, day
3384 month = m.group('month')
3385 day = 1
3386 if month is None:
3387 month = 1
3388 else:
3389 month = int(month)
3390 day = m.group('day')
3391 if day:
3392 day = int(day)
3393 else:
3394 day = 1
3395 return year, month, day
3396
3397 def __extract_time(m):
3398 if not m:
3399 return 0, 0, 0
3400 hours = m.group('hours')
3401 if not hours:
3402 return 0, 0, 0
3403 hours = int(hours)
3404 minutes = int(m.group('minutes'))
3405 seconds = m.group('seconds')
3406 if seconds:
3407 seconds = int(seconds)
3408 else:
3409 seconds = 0
3410 return hours, minutes, seconds
3411
3412 def __extract_tzd(m):

Callers 3

_parse_date_onblogFunction · 0.85
_parse_date_nateFunction · 0.85
_parse_date_hungarianFunction · 0.85

Calls 5

__extract_dateFunction · 0.85
__extract_timeFunction · 0.85
__extract_tzdFunction · 0.85
matchMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…