# Path: src/bin/syndication_app/feedparser/datetimes/rfc822.py
# def _parse_date_rfc822(date):
#     """Parse RFC 822 dates and times
#     http://tools.ietf.org/html/rfc822#section-5
# 
#     There are some formatting differences that are accounted for:
#     1. Years may be two or four digits.
#     2. The month and day can be swapped.
#     3. Additional timezone names are supported.
#     4. A default time and timezone are assumed if only a date is present.
# 
#     :param str date: a date/time string that will be converted to a time tuple
#     :returns: a UTC time tuple, or None
#     :rtype: time.struct_time | None
#     """
# 
#     parts = date.lower().split()
#     if len(parts) < 5:
#         # Assume that the time and timezone are missing
#         parts.extend(('00:00:00', '0000'))
#     # Remove the day name
#     if parts[0][:3] in day_names:
#         parts = parts[1:]
#     if len(parts) < 5:
#         # If there are still fewer than five parts, there's not enough
#         # information to interpret this.
#         return None
# 
#     # Handle the day and month name.
#     month = months.get(parts[1][:3])
#     try:
#         day = int(parts[0])
#     except ValueError:
#         # Check if the day and month are swapped.
#         if months.get(parts[0][:3]):
#             try:
#                 day = int(parts[1])
#             except ValueError:
#                 return None
#             month = months.get(parts[0][:3])
#         else:
#             return None
#     if not month:
#         return None
# 
#     # Handle the year.
#     try:
#         year = int(parts[2])
#     except ValueError:
#         return None
#     # Normalize two-digit years:
#     # Anything in the 90's is interpreted as 1990 and on.
#     # Anything 89 or less is interpreted as 2089 or before.
#     if len(parts[2]) <= 2:
#         year += (1900, 2000)[year < 90]
# 
#     # Handle the time (default to 00:00:00).
#     time_parts = parts[3].split(':')
#     time_parts.extend(('0',) * (3 - len(time_parts)))
#     try:
#         (hour, minute, second) = [int(i) for i in time_parts]
#     except ValueError:
#         return None
# 
#     # Handle the timezone information, if any (default to +0000).
#     # Strip 'Etc/' from the timezone.
#     if parts[4].startswith('etc/'):
#         parts[4] = parts[4][4:]
#     # Normalize timezones that start with 'gmt':
#     # GMT-05:00 => -0500
#     # GMT => GMT
#     if parts[4].startswith('gmt'):
#         parts[4] = ''.join(parts[4][3:].split(':')) or 'gmt'
#     # Handle timezones like '-0500', '+0500', and 'EST'
#     if parts[4] and parts[4][0] in ('-', '+'):
#         try:
#             timezone_hours = int(parts[4][1:3])
#             timezone_minutes = int(parts[4][3:])
#         except ValueError:
#             return None
#         if parts[4].startswith('-'):
#             timezone_hours *= -1
#             timezone_minutes *= -1
#     else:
#         timezone_hours = timezone_names.get(parts[4], 0)
#         timezone_minutes = 0
# 
#     # Create the datetime object and timezone delta objects
#     try:
#         stamp = datetime.datetime(year, month, day, hour, minute, second)
#     except ValueError:
#         return None
#     delta = datetime.timedelta(0, 0, 0, 0, timezone_minutes, timezone_hours)
# 
#     # Return the date and timestamp in a UTC 9-tuple
#     try:
#         return (stamp - delta).utctimetuple()
#     except (OverflowError, ValueError):
#         # IronPython throws ValueErrors instead of OverflowErrors
#         return None


import re
from .rfc822 import _parse_date_rfc822
   '\u039a\u03c5\u03c1': 'Sun', # caf5f1 in iso-8859-7
   '\u0394\u03b5\u03c5': 'Mon', # c4e5f5 in iso-8859-7
   '\u03a4\u03c1\u03b9': 'Tue', # d4f1e9 in iso-8859-7
   '\u03a4\u03b5\u03c4': 'Wed', # d4e5f4 in iso-8859-7
   '\u03a0\u03b5\u03bc': 'Thu', # d0e5ec in iso-8859-7
   '\u03a0\u03b1\u03c1': 'Fri', # d0e1f1 in iso-8859-7
   '\u03a3\u03b1\u03b2': 'Sat', # d3e1e2 in iso-8859-7
}

_greek_date_format_re = re.compile(r'([^,]+),\s+(\d{2})\s+([^\s]+)\s+(\d{4})\s+(\d{2}):(\d{2}):(\d{2})\s+([^\s]+)')


def _parse_date_greek(date_string):
    """Parse a string according to a Greek 8-bit date format."""
    m = _greek_date_format_re.match(date_string)
    if not m:
        return
    wday = _greek_wdays[m.group(1)]
    month = _greek_months[m.group(3)]
    rfc822date = '%(wday)s, %(day)s %(month)s %(year)s %(hour)s:%(minute)s:%(second)s %(zonediff)s' % \
                 {
                     'wday': wday,
                     'day': m.group(2),
                     'month': month,
                     'year': m.group(4),
                     'hour': m.group(5),
                     'minute': m.group(6),
                     'second': m.group(7),
                     'zonediff': m.group(8),
                 }

# Path: src/bin/syndication_app/feedparser/datetimes/rfc822.py
# def _parse_date_rfc822(date):
#     """Parse RFC 822 dates and times
#     http://tools.ietf.org/html/rfc822#section-5
# 
#     There are some formatting differences that are accounted for:
#     1. Years may be two or four digits.
#     2. The month and day can be swapped.
#     3. Additional timezone names are supported.
#     4. A default time and timezone are assumed if only a date is present.
# 
#     :param str date: a date/time string that will be converted to a time tuple
#     :returns: a UTC time tuple, or None
#     :rtype: time.struct_time | None
#     """
# 
#     parts = date.lower().split()
#     if len(parts) < 5:
#         # Assume that the time and timezone are missing
#         parts.extend(('00:00:00', '0000'))
#     # Remove the day name
#     if parts[0][:3] in day_names:
#         parts = parts[1:]
#     if len(parts) < 5:
#         # If there are still fewer than five parts, there's not enough
#         # information to interpret this.
#         return None
# 
#     # Handle the day and month name.
#     month = months.get(parts[1][:3])
#     try:
#         day = int(parts[0])
#     except ValueError:
#         # Check if the day and month are swapped.
#         if months.get(parts[0][:3]):
#             try:
#                 day = int(parts[1])
#             except ValueError:
#                 return None
#             month = months.get(parts[0][:3])
#         else:
#             return None
#     if not month:
#         return None
# 
#     # Handle the year.
#     try:
#         year = int(parts[2])
#     except ValueError:
#         return None
#     # Normalize two-digit years:
#     # Anything in the 90's is interpreted as 1990 and on.
#     # Anything 89 or less is interpreted as 2089 or before.
#     if len(parts[2]) <= 2:
#         year += (1900, 2000)[year < 90]
# 
#     # Handle the time (default to 00:00:00).
#     time_parts = parts[3].split(':')
#     time_parts.extend(('0',) * (3 - len(time_parts)))
#     try:
#         (hour, minute, second) = [int(i) for i in time_parts]
#     except ValueError:
#         return None
# 
#     # Handle the timezone information, if any (default to +0000).
#     # Strip 'Etc/' from the timezone.
#     if parts[4].startswith('etc/'):
#         parts[4] = parts[4][4:]
#     # Normalize timezones that start with 'gmt':
#     # GMT-05:00 => -0500
#     # GMT => GMT
#     if parts[4].startswith('gmt'):
#         parts[4] = ''.join(parts[4][3:].split(':')) or 'gmt'
#     # Handle timezones like '-0500', '+0500', and 'EST'
#     if parts[4] and parts[4][0] in ('-', '+'):
#         try:
#             timezone_hours = int(parts[4][1:3])
#             timezone_minutes = int(parts[4][3:])
#         except ValueError:
#             return None
#         if parts[4].startswith('-'):
#             timezone_hours *= -1
#             timezone_minutes *= -1
#     else:
#         timezone_hours = timezone_names.get(parts[4], 0)
#         timezone_minutes = 0
# 
#     # Create the datetime object and timezone delta objects
#     try:
#         stamp = datetime.datetime(year, month, day, hour, minute, second)
#     except ValueError:
#         return None
#     delta = datetime.timedelta(0, 0, 0, 0, timezone_minutes, timezone_hours)
# 
#     # Return the date and timestamp in a UTC 9-tuple
#     try:
#         return (stamp - delta).utctimetuple()
#     except (OverflowError, ValueError):
#         # IronPython throws ValueErrors instead of OverflowErrors
#         return None


# Path: src/bin/syndication_app/feedparser/datetimes/greek.py
import re
from .rfc822 import _parse_date_rfc822

   '\u039a\u03c5\u03c1': 'Sun', # caf5f1 in iso-8859-7
   '\u0394\u03b5\u03c5': 'Mon', # c4e5f5 in iso-8859-7
   '\u03a4\u03c1\u03b9': 'Tue', # d4f1e9 in iso-8859-7
   '\u03a4\u03b5\u03c4': 'Wed', # d4e5f4 in iso-8859-7
   '\u03a0\u03b5\u03bc': 'Thu', # d0e5ec in iso-8859-7
   '\u03a0\u03b1\u03c1': 'Fri', # d0e1f1 in iso-8859-7
   '\u03a3\u03b1\u03b2': 'Sat', # d3e1e2 in iso-8859-7
}

_greek_date_format_re = re.compile(r'([^,]+),\s+(\d{2})\s+([^\s]+)\s+(\d{4})\s+(\d{2}):(\d{2}):(\d{2})\s+([^\s]+)')


def _parse_date_greek(date_string):
    """Parse a string according to a Greek 8-bit date format."""
    m = _greek_date_format_re.match(date_string)
    if not m:
        return
    wday = _greek_wdays[m.group(1)]
    month = _greek_months[m.group(3)]
    rfc822date = '%(wday)s, %(day)s %(month)s %(year)s %(hour)s:%(minute)s:%(second)s %(zonediff)s' % \
                 {
                     'wday': wday,
                     'day': m.group(2),
                     'month': month,
                     'year': m.group(4),
                     'hour': m.group(5),
                     'minute': m.group(6),
                     'second': m.group(7),
                     'zonediff': m.group(8),
                 }

    return _parse_date_rfc822(rfc822date)