+ zodiac sign
This commit is contained in:
parent
3f98831071
commit
5f5beada4e
@ -1,16 +1,22 @@
|
|||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys
|
|
||||||
import yaml
|
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import sys
|
||||||
|
from bisect import bisect
|
||||||
|
import yaml
|
||||||
from icalendar import Calendar, Event
|
from icalendar import Calendar, Event
|
||||||
|
|
||||||
one_day = datetime.date(1, 1, 2) - datetime.date(1, 1, 1)
|
one_day = datetime.date(1, 1, 2) - datetime.date(1, 1, 1)
|
||||||
|
|
||||||
event_config = {'description': '', 'categories': '', 'language': ''}
|
event_config = {'description': '', 'categories': '', 'language': ''}
|
||||||
|
|
||||||
|
zsigns = [(1, 20, '♑'), (2, 18, '♒'), (3, 20, '♓'), (4, 20, '♈'),
|
||||||
|
(5, 21, '♉'), (6, 21, '♊'), (7, 22, '♋'), (8, 23, '♌'),
|
||||||
|
(9, 23, '♍'), (10, 23, '♎'), (11, 22, '♏'), (12, 22, '♐'),
|
||||||
|
(12, 31, '♑')]
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
result = dict()
|
result = dict()
|
||||||
@ -52,6 +58,11 @@ def age(person, year):
|
|||||||
return abs(year - person['birthday'].year)
|
return abs(year - person['birthday'].year)
|
||||||
|
|
||||||
|
|
||||||
|
def zodiac_sign(person):
|
||||||
|
birthday = person['birthday']
|
||||||
|
return zsigns[bisect(zsigns, (birthday.month, birthday.day))][2]
|
||||||
|
|
||||||
|
|
||||||
def make_event(person, year):
|
def make_event(person, year):
|
||||||
event_date = person['birthday'].replace(year=year)
|
event_date = person['birthday'].replace(year=year)
|
||||||
description = event_config['description']
|
description = event_config['description']
|
||||||
@ -59,7 +70,7 @@ def make_event(person, year):
|
|||||||
lang_params = {'language': event_config['language']}
|
lang_params = {'language': event_config['language']}
|
||||||
|
|
||||||
if 'birthday_no_year' not in person:
|
if 'birthday_no_year' not in person:
|
||||||
description += ', %d' % age(person, year)
|
description += ', %d %s' % (age(person, year), zodiac_sign(person))
|
||||||
|
|
||||||
event = Event()
|
event = Event()
|
||||||
event.add('uid', sha1(person['name'] + ' birthday ' + str(year)))
|
event.add('uid', sha1(person['name'] + ' birthday ' + str(year)))
|
||||||
|
Loading…
Reference in New Issue
Block a user