home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / plugins / facebook / content_translation.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  1.3 KB  |  43 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4.  
  5. def get_birthdays(bdays, now):
  6.     import datetime
  7.     today = datetime.date.fromtimestamp(now)
  8.     new = { }
  9.     for uid, d_ in bdays.items():
  10.         bd = d_.get('birthday_date')
  11.         if bd is not None:
  12.             mdy = [
  13.                 None] * 3
  14.             vals = [ int(i) for i in bd.split('/') ]
  15.             mdy[:len(vals)] = vals
  16.             (m, d, y) = mdy
  17.             bd_date_this = datetime.date(today.year, m, d)
  18.             bd_date_next = datetime.date(today.year + 1, m, d)
  19.             keep = False
  20.             if (bd_date_this - today).days < (bd_date_this - today).days:
  21.                 pass
  22.             elif (bd_date_this - today).days <= 7:
  23.                 keep = True
  24.                 bd_date = bd_date_this
  25.             elif (bd_date_next - today).days < (bd_date_next - today).days:
  26.                 pass
  27.             elif (bd_date_next - today).days <= 7:
  28.                 keep = True
  29.                 bd_date = bd_date_next
  30.             
  31.             if keep:
  32.                 new[uid] = dict(d_)
  33.                 new[uid]['bday'] = bd_date
  34.                 if y is not None:
  35.                     born_on = datetime.date(y, m, d)
  36.                     new[uid]['age'] = int(((bd_date - born_on).days + 1) / 365)
  37.                 
  38.             
  39.         keep
  40.     
  41.     return sorted(new.items(), key = (lambda foo: foo[1]['bday']))
  42.  
  43.