# Path: floyd/util/unicode.py
# def force_unicode(text, encoding='utf-8'):
#   """
#   
#   @TODO encoding support
#   """
#   if text == None:
#     return u''
# 
#   try:
#     text = unicode(text, 'utf-8')
#   except UnicodeDecodeError:
#     text = unicode(text, 'latin1')
#   except TypeError:
#     text = unicode(text)
#   return text
# 
# def force_utf8(text):
#   return str(force_unicode(text).encode('utf8'))
# 
# Path: floyd/util/dates.py
# MONTHS = {
#     1:_('January'), 2:_('February'), 3:_('March'), 4:_('April'), 5:_('May'), 6:_('June'),
#     7:_('July'), 8:_('August'), 9:_('September'), 10:_('October'), 11:_('November'),
#     12:_('December')
# }
# 
# MONTHS_3 = {
#     1:_('jan'), 2:_('feb'), 3:_('mar'), 4:_('apr'), 5:_('may'), 6:_('jun'),
#     7:_('jul'), 8:_('aug'), 9:_('sep'), 10:_('oct'), 11:_('nov'), 12:_('dec')
# }
# 
# MONTHS_AP = { # month names in Associated Press style
#     1:_('Jan.'), 2:_('Feb.'), 3:_('March'), 4:_('April'), 5:_('May'), 6:_('June'), 7:_('July'),
#     8:_('Aug.'), 9:_('Sept.'), 10:_('Oct.'), 11:_('Nov.'), 12:_('Dec.')
# }
# 
# WEEKDAYS = {
#     0:_('Monday'), 1:_('Tuesday'), 2:_('Wednesday'), 3:_('Thursday'), 4:_('Friday'),
#     5:_('Saturday'), 6:_('Sunday')
# }
# 
# WEEKDAYS_ABBR = {
#     0:_('Mon'), 1:_('Tue'), 2:_('Wed'), 3:_('Thu'), 4:_('Fri'),
#     5:_('Sat'), 6:_('Sun')
# }
# 
# Path: floyd/util/translation.py
# def ugettext(str, format=unicode):
#   return force_unicode(str)


import re
import time
import calendar
import time
from datetime import tzinfo, timedelta
from floyd.util.unicode import force_unicode, force_utf8
from floyd.util.dates import MONTHS, MONTHS_3, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR
from floyd.util.translation import ugettext as _
  from email.utils import formatdate
  from rfc822 import formatdate as HTTPDate
  year_days = [None, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]

  def __init__(self, dt):
    # Accepts either a datetime or date object.
    self.data = dt
    self.timezone = getattr(dt, 'tzinfo', None)
    if hasattr(self.data, 'hour') and not self.timezone:
      self.timezone = LocalTimezone(dt)

  def b(self):
    "Month, textual, 3 letters, lowercase; e.g. 'jan'"
    return MONTHS_3[self.data.month]

  def c(self):
    """
    ISO 8601 Format
    Example : '2008-01-02T10:30:00.000123'
    """
    return self.data.isoformat()

  def d(self):
    "Day of the month, 2 digits with leading zeros; i.e. '01' to '31'"
    return u'%02d' % self.data.day

  def D(self):
    "Day of the week, textual, 3 letters; e.g. 'Fri'"
    return WEEKDAYS_ABBR[self.data.weekday()]

  def F(self):
    "Month, textual, long; e.g. 'January'"

# Path: floyd/util/unicode.py
# def force_unicode(text, encoding='utf-8'):
#   """
#   
#   @TODO encoding support
#   """
#   if text == None:
#     return u''
# 
#   try:
#     text = unicode(text, 'utf-8')
#   except UnicodeDecodeError:
#     text = unicode(text, 'latin1')
#   except TypeError:
#     text = unicode(text)
#   return text
# 
# def force_utf8(text):
#   return str(force_unicode(text).encode('utf8'))
# 
# Path: floyd/util/dates.py
# MONTHS = {
#     1:_('January'), 2:_('February'), 3:_('March'), 4:_('April'), 5:_('May'), 6:_('June'),
#     7:_('July'), 8:_('August'), 9:_('September'), 10:_('October'), 11:_('November'),
#     12:_('December')
# }
# 
# MONTHS_3 = {
#     1:_('jan'), 2:_('feb'), 3:_('mar'), 4:_('apr'), 5:_('may'), 6:_('jun'),
#     7:_('jul'), 8:_('aug'), 9:_('sep'), 10:_('oct'), 11:_('nov'), 12:_('dec')
# }
# 
# MONTHS_AP = { # month names in Associated Press style
#     1:_('Jan.'), 2:_('Feb.'), 3:_('March'), 4:_('April'), 5:_('May'), 6:_('June'), 7:_('July'),
#     8:_('Aug.'), 9:_('Sept.'), 10:_('Oct.'), 11:_('Nov.'), 12:_('Dec.')
# }
# 
# WEEKDAYS = {
#     0:_('Monday'), 1:_('Tuesday'), 2:_('Wednesday'), 3:_('Thursday'), 4:_('Friday'),
#     5:_('Saturday'), 6:_('Sunday')
# }
# 
# WEEKDAYS_ABBR = {
#     0:_('Mon'), 1:_('Tue'), 2:_('Wed'), 3:_('Thu'), 4:_('Fri'),
#     5:_('Sat'), 6:_('Sun')
# }
# 
# Path: floyd/util/translation.py
# def ugettext(str, format=unicode):
#   return force_unicode(str)


# Path: floyd/util/dateformat.py
import re
import time
import calendar
import time
from datetime import tzinfo, timedelta
from floyd.util.unicode import force_unicode, force_utf8
from floyd.util.dates import MONTHS, MONTHS_3, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR
from floyd.util.translation import ugettext as _
  from email.utils import formatdate
  from rfc822 import formatdate as HTTPDate

  year_days = [None, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]

  def __init__(self, dt):
    # Accepts either a datetime or date object.
    self.data = dt
    self.timezone = getattr(dt, 'tzinfo', None)
    if hasattr(self.data, 'hour') and not self.timezone:
      self.timezone = LocalTimezone(dt)

  def b(self):
    "Month, textual, 3 letters, lowercase; e.g. 'jan'"
    return MONTHS_3[self.data.month]

  def c(self):
    """
    ISO 8601 Format
    Example : '2008-01-02T10:30:00.000123'
    """
    return self.data.isoformat()

  def d(self):
    "Day of the month, 2 digits with leading zeros; i.e. '01' to '31'"
    return u'%02d' % self.data.day

  def D(self):
    "Day of the week, textual, 3 letters; e.g. 'Fri'"
    return WEEKDAYS_ABBR[self.data.weekday()]

  def F(self):
    "Month, textual, long; e.g. 'January'"

    return MONTHS[self.data.month]