Ejemplo n.º 1
0
def get_bio_data(birthday_dt, period):
    '''
    получить данные для графиков

    birthday_dt - дата рождения
    period - период, в которым интересны данные
        [0] - дата начала прериода,
        [1] - дата окончания периода
    '''

    return [
        {
            'day': yyyy_mm_dd(
                date_shift(
                    *(birthday_dt + [t,])
                )
            ),
            'fiz': int(bio(t, PHYSICAL_PERIOD)),
            'emo': int(bio(t, EMOTIONAL_PERIOD)),
            'smart': int(bio(t, BRAIN_PERIOD)),
        }
        for t in xrange(
            date_diff(period[0], birthday_dt),
            date_diff(period[1], birthday_dt)+1
        )
    ]
Ejemplo n.º 2
0
def git_important_days(birthday_dt, period):
    '''
    получаем список особых дней за указанный период
    birthday_dt - дата рождения
    period - период, в который нужно получить особые даты
        [0] - дата начала прериода,
        [1] - дата окончания периода
    '''
    days = {}
    _day = period[0]
    while date_compare( *(_day+period[1]) )  != -1:
        time_diff = date_diff(_day, birthday_dt)

        critical = get_critical_preiods(_day, time_diff)
        peak = get_peak_preiods(_day, time_diff)
        day = yyyy_mm_dd(_day)

        if (peak or critical):
            days.setdefault(
                day, {
                    'biorythms': day_bio(time_diff),
                    'day': yyyy_mm_dd(_day)
                }
            )
        if peak:
            days[day].update(peak)
        if critical:
            days[day].update(critical)

        _day = date_shift(*(_day + (1,)))
    return collections.OrderedDict(sorted(days.items()))
Ejemplo n.º 3
0
 def get_period(date1, date2):
     list_d = [date1]
     current_date = date1
     while date.date_compare(*current_date + date2) == 1:
         current_date = date.date_shift(*current_date + (1,))
         list_d.append(current_date)
     return list_d
Ejemplo n.º 4
0
def snct_minc(date, diff):

    diff = int(diff)
    _date = date_to_dict(date)
    sign = diff/abs(diff)
    sift = 0
    for i in xrange(min(0, diff), max(0, diff)):
        sift += num_days_in_month(_date[1], _date[2])
        _date = date_shift(
            *(_date + [sign*sift])
        )
    return yyyy_mm_dd(_date)
Ejemplo n.º 5
0
 def formatmonthname(self, theyear, themonth, withyear=True):
     with calendar.TimeEncoding(self.locale) as encoding:
         s = calendar.month_name[themonth]
         if encoding is not None:
             s = s.decode(encoding)
         if withyear and theyear != self.today.year:
             s = '%s, %s' % (s, theyear)
         prev_month_day = yyyy_mm_dd(
             date_shift(1, themonth, theyear, -1)
         )
         next_month_day = yyyy_mm_dd(
             date_shift(
                 num_days_in_month(themonth,theyear),
                 themonth, theyear, 1
             )
         )
         return (
             '<tr><th colspan="7" class="month">'
             '<a href="#" day="%s" class="get_bio_data">&larr;</a> '
             '%s'
             ' <a href="#" day="%s" class="get_bio_data">&rarr;</a>'
             '</th></tr>'
         )% (prev_month_day, s, next_month_day)
Ejemplo n.º 6
0
def snct_dinc(date, diff):
    return yyyy_mm_dd(
        date_shift(
            *(date_to_dict(date) + [int(diff)])
        )
    )