コード例 #1
0
ファイル: calendar.py プロジェクト: APSL/django-blog-zinnia
 def __init__(self):
     """
     Retrieve and convert the localized first week day
     at initialization.
     """
     HTMLCalendar.__init__(self, AMERICAN_TO_EUROPEAN_WEEK_DAYS[
         get_format('FIRST_DAY_OF_WEEK')])
コード例 #2
0
 def __init__(self):
     """Retrieve and convert the localized first week day
     at initialization"""
     localized_first_week_day = get_format('FIRST_DAY_OF_WEEK')
     if not localized_first_week_day:
         HTMLCalendar.__init__(self, 6)
     else:
         HTMLCalendar.__init__(self, localized_first_week_day - 1)
コード例 #3
0
ファイル: views.py プロジェクト: ns-plamen/myproject
def time(request):
    monthCal = HTMLCalendar(calendar.MONDAY)
    now = datetime.date.today()
    date_0 = now.year
    date_1 = now.month
    date_2 = now.day
    my_cal = monthCal.formatmonth (date_0 ,date_1 )
    my_cal = my_cal.replace ('">%r</td><td class="' %date_2, '"<p style="color:#FF0000">%r</p></td><td class="' %date_2)
    return render_to_response ('asd/time.html', {'current_date': now, 'cal': my_cal  })
コード例 #4
0
ファイル: views.py プロジェクト: alanleegithub/webfaction
def blog(request, post_id = 1):
    if not(request.user.is_authenticated()):
       request.user.username = '******'

    c = HTMLCalendar(6).formatmonth(date.today().year, date.today().month)
    c = c.replace('>%s</td>' % date.today().day,
                  '><u><a href=#>%s</a></u></td>' % date.today().day)
    return render_to_response('blog.html',
           {'post': Post.objects.get(id = post_id),
            'user': request.user,
            'calendar': c, })
コード例 #5
0
ファイル: views.py プロジェクト: alanleegithub/webfaction
def blogs(request):
    if not(request.user.is_authenticated()):
       request.user.username = '******'

    c = HTMLCalendar(6).formatmonth(date.today().year, date.today().month)
    c = c.replace('>%s</td>' % date.today().day,
                  '><u><a href=#>%s</a></u></td>' % date.today().day)
    return render_to_response('blogs.html',
           {'blogs': Post.objects.all().order_by('-published_date'),
            'user': request.user,
            'calendar': c, }, context_instance=RequestContext(request))
コード例 #6
0
ファイル: dashboard.py プロジェクト: SpreadBand/SpreadBand
    def __init__(self, firstweekday, aQueryset, when):
        HTMLCalendar.__init__(self, firstweekday)

        # Prepare a date-indexed list of gigbargains
        # XXX Maybe it's possible to do it using a query, but I don't know how
        self._gigbargains = defaultdict(list)
        for gigbargain in aQueryset:
            self._gigbargains[gigbargain.date].append(gigbargain)

        self._when = when

        self.today = date.today()
コード例 #7
0
ファイル: views.py プロジェクト: romaintha/holiday_planner
 def calendar_with_link(year, month):
     """
     This takes a HTMLCalendar.formatmonth string as input and add a href to
     every days
     """
     HTMLCalendar_string = HTMLCalendar(0).formatmonth(int(year), int(month))
     for day in range(1,32) :
         #identify the position of the day in the string
         former = '>%s<' %(day,)
         day_link = reverse('my_profile:day_status', kwargs={'year': year,
                                                             'month': month,
                                                             'day': '{:0>2}'.format(day)})
         new = '><a href="%s" >%s</a><' %(day_link, day)
         HTMLCalendar_string = HTMLCalendar_string.replace(former, new)
     return HTMLCalendar_string
コード例 #8
0
ファイル: month_builder.py プロジェクト: LechX/crabgrab
from calendar import HTMLCalendar
import pickle
import os.path

theyear = 2017
themonth = 2

scriptpath = os.path.dirname(__file__)
filename = os.path.join(scriptpath, 'brighton_list.txt')
tide_file = open(filename, "rb")
tide_data = pickle.load(tide_file)


html_cal = HTMLCalendar(firstweekday=6)
v = []
a = v.append
a('\n')
a('<table border="0" cellpadding="0" cellspacing="2px" class="month">')
a('\n')
a(html_cal.formatmonthname(theyear, themonth, withyear=True))
a('\n')
a(html_cal.formatweekheader())
a('\n')
for week in html_cal.monthdays2calendar(theyear, themonth):
    w = ''
    for (d, wd) in week:
        if d == 0:
            w += '<td class="noday">&nbsp;</td>' # day outside month
        else:
            daily_info = ''
            for entry in tide_data:
コード例 #9
0
ファイル: tut_calendar.py プロジェクト: rupav/ExpenseManager
from calendar import Calendar, TextCalendar, HTMLCalendar, calendar

cal = Calendar()
iter = cal.iterweekdays()
for i in iter:
    print(i)

#cal.TextCalendar()
html_cal = HTMLCalendar()
code = html_cal.formatmonth(2017, 12, False)
code = html_cal.formatyear(2017, 6)  # in HTML Format!
code = html_cal.formatyearpage(2017, encoding='UTF-8')
code = calendar(2017)  # In text !
print(code)
コード例 #10
0
def dashboard():
    html_cal = HTMLCalendar()
    html_code = html_cal.formatmonth(datetime.today().year,
                                     datetime.today().month, True)
    username = session['username']
    user_email = User.query.filter_by(username=username).first().email
    daily_cats = Category.query.filter_by(category_daily=True).all()
    pie_data = [
        pie_chart([cat for cat in CATS['Daily'] + CATS['Monthly']],
                  convert_toPercent([
                      calculate_expenditure(category_object.id,
                                            userid=User.query.filter_by(
                                                username=username).first().id,
                                            today=False)
                      for category_object in Category.query.all()
                  ]), "My Expenditure Distribution this Month."),
        pie_chart([cat for cat in CATS['Daily']],
                  convert_toPercent([
                      calculate_expenditure(category_object.id,
                                            userid=User.query.filter_by(
                                                username=username).first().id,
                                            today=True)
                      for category_object in Category.query.all()
                  ]), "My Expenditure Distribution today!")
    ]
    months = [
        'Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', 'Aug', 'Sept',
        'Oct', 'Nov', 'Dec'
    ]
    l = [
        calculate_expenditureBudget_month(
            userid=User.query.filter_by(username=username).first().id,
            month=month) for month in range(1, 13)
    ]
    exp, budg = zip(*l)
    gauge_data = gauge_chart(
        ['{}{}'.format(a, b) for a, b in zip(months, [' Expenses'] * 12)], exp,
        budg)

    _budg = budg[datetime.today().month - 1]
    _exp = exp[datetime.today().month - 1]
    if _budg > 1:
        if _exp > _budg:
            flash(
                "You have exceeded your budget limit this month by {} Rs.".
                format(_exp - _budg), "danger")
        elif _exp == _budg:
            flash(
                "Expenses equalled to budget this month, time to stop spending",
                "warning")
        else:
            flash(
                "Keep spending, you have {} Rs. to spend".format(_budg - _exp),
                "success")

    try:
        if request.method == 'POST':
            initialize_categories()
            username = session['username']

            if request.form['submit'] == "Set Password":
                new_password = request.form['NewPassword']
                new_password = sha256_crypt.encrypt(str(new_password))
                User.query.filter_by(
                    username=username).first().password = new_password
                db.session.commit()
                db.session.close()
                session.clear()
                gc.collect()
                flash("Password Changed!", "success")
                flash("Login Again!")
                return redirect(url_for('login_page'))
            if request.form['submit'] == 'Save Email':
                new_email = request.form['email']
                User.query.filter_by(
                    username=username).first().email = new_email
                db.session.commit()
                db.session.close()
                gc.collect()
                flash("Email changed", "success")
                return render_template('dashboard.html',
                                       CATS=CATS,
                                       html_code=html_code,
                                       active_tab='Home',
                                       isDaily=True,
                                       pie_data=pie_data,
                                       gauge_data=gauge_data,
                                       user_email=user_email)

            if request.form['submit'] == "Set Budget":
                _budget_userid = User.query.filter_by(
                    username=username).first().id
                flag = 0

                for obj in Budget.query.filter_by(
                        budget_userid=_budget_userid).all():
                    if obj.budget_year == datetime.today(
                    ).year and obj.budget_month == datetime.today().month:
                        flash(
                            "Budget successfully changed for this month! from {} to {}"
                            .format(
                                obj.budget_amount,
                                request.form['amount'],
                            ), "success")
                        obj.budget_amount = request.form['amount']
                        db.session.commit()
                        db.session.close()
                        gc.collect()
                        flag = 1
                    # now don't need to create object again.

                if flag == 0:
                    _budget_amount = request.form['amount']
                    _budget_month = datetime.today().month
                    _budget_year = datetime.today().year
                    budget_object = Budget(budget_userid=_budget_userid,
                                           budget_year=_budget_year,
                                           budget_month=_budget_month,
                                           budget_amount=_budget_amount)
                    db.session.add(budget_object)
                    db.session.commit()
                    session['current_budget_id'] = budget_object.id
                    db.session.close()
                    gc.collect()
                    flash("Budget Set!", "success")

                l = [
                    calculate_expenditureBudget_month(
                        userid=User.query.filter_by(
                            username=username).first().id,
                        month=month) for month in range(1, 13)
                ]
                exp, budg = zip(*l)
                gauge_data = gauge_chart([
                    '{}{}'.format(a, b)
                    for a, b in zip(months, [' Expenses'] * 12)
                ], exp, budg)

                return render_template('dashboard.html',
                                       CATS=CATS,
                                       html_code=html_code,
                                       active_tab='Home',
                                       isDaily=True,
                                       pie_data=pie_data,
                                       gauge_data=gauge_data,
                                       user_email=user_email)

            for key in CATS.keys():
                for cat in CATS[key]:
                    if request.form['submit'] == "Set {} amount".format(cat):
                        _expenditure_userid = User.query.filter_by(
                            username=username).first().id
                        _spent = request.form['amount']
                        _where_spent = request.form['location']
                        _category_id = Category.query.filter_by(
                            category=cat).first().id
                        _date_of_expenditure = datetime.today()
                        _description = request.form['comment']
                        expenditure_object = Expenditure(
                            expenditure_userid=_expenditure_userid,
                            spent=_spent,
                            where_spent=_where_spent,
                            category_id=_category_id,
                            date_of_expenditure=_date_of_expenditure,
                            description=_description)
                        db.session.add(expenditure_object)
                        db.session.commit()
                        db.session.close()
                        gc.collect()
                        flash("Expenditure recorded of {}!".format(cat),
                              "success")

                        pie_data = [
                            pie_chart(
                                [
                                    cat
                                    for cat in CATS['Daily'] + CATS['Monthly']
                                ],
                                convert_toPercent([
                                    calculate_expenditure(
                                        category_object.id,
                                        userid=User.query.filter_by(
                                            username=username).first().id,
                                        today=False) for category_object in
                                    Category.query.all()
                                ]), "My Expenditure Distribution this Month."),
                            pie_chart(
                                [cat for cat in CATS['Daily']],
                                convert_toPercent([
                                    calculate_expenditure(
                                        category_object.id,
                                        userid=User.query.filter_by(
                                            username=username).first().id,
                                        today=True) for category_object in
                                    Category.query.all()
                                ]), "My Expenditure Distribution today!")
                        ]

                        l = [
                            calculate_expenditureBudget_month(
                                userid=User.query.filter_by(
                                    username=username).first().id,
                                month=month) for month in range(1, 13)
                        ]
                        exp, budg = zip(*l)
                        gauge_data = gauge_chart([
                            '{}{}'.format(a, b)
                            for a, b in zip(months, [' Expenses'] * 12)
                        ], exp, budg)

                        if Category.query.filter_by(
                                category=cat).first().category_daily == True:
                            return render_template('dashboard.html',
                                                   CATS=CATS,
                                                   html_code=html_code,
                                                   active_tab='expense',
                                                   isDaily=True,
                                                   pie_data=pie_data,
                                                   gauge_data=gauge_data,
                                                   user_email=user_email)
                        else:
                            return render_template('dashboard.html',
                                                   CATS=CATS,
                                                   html_code=html_code,
                                                   active_tab='expense',
                                                   isDaily=False,
                                                   pie_data=pie_data,
                                                   gauge_data=gauge_data,
                                                   user_email=user_email)

            return render_template('dashboard.html',
                                   CATS=CATS,
                                   html_code=html_code,
                                   active_tab='Home')
        else:
            flash("Welcome!", "default")
            return render_template('dashboard.html',
                                   CATS=CATS,
                                   html_code=html_code,
                                   active_tab='Home',
                                   pie_data=pie_data,
                                   gauge_data=gauge_data,
                                   user_email=user_email)
    except Exception as e:
        return render_template('error.html', e=e)
コード例 #11
0
from calendar import HTMLCalendar

html = HTMLCalendar().formatmonth(1969, 7)

print(html)
# <table border="0" cellpadding="0" cellspacing="0" class="month">
# <tr><th colspan="7" class="month">July 1969</th></tr>
# <tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>
# <tr><td class="noday">&nbsp;</td><td class="tue">1</td><td class="wed">2</td><td class="thu">3</td><td class="fri">4</td><td class="sat">5</td><td class="sun">6</td></tr>
# <tr><td class="mon">7</td><td class="tue">8</td><td class="wed">9</td><td class="thu">10</td><td class="fri">11</td><td class="sat">12</td><td class="sun">13</td></tr>
# <tr><td class="mon">14</td><td class="tue">15</td><td class="wed">16</td><td class="thu">17</td><td class="fri">18</td><td class="sat">19</td><td class="sun">20</td></tr>
# <tr><td class="mon">21</td><td class="tue">22</td><td class="wed">23</td><td class="thu">24</td><td class="fri">25</td><td class="sat">26</td><td class="sun">27</td></tr>
# <tr><td class="mon">28</td><td class="tue">29</td><td class="wed">30</td><td class="thu">31</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>
# </table>
コード例 #12
0
ファイル: views.py プロジェクト: lnalkman/education_platform
 def formatmonth(self, theyear=None, themonth=None, withyear=False):
     return HTMLCalendar.formatmonth(self, theyear or self.theyear, themonth
                                     or self.themonth, withyear)
コード例 #13
0
def calendarpage(request):
    cal = HTMLCalendar()
    monthly = cal.formatmonth(2016, 5)
    return render(request, 'Lfit/calendarproto.html', {'monthly': monthly})
コード例 #14
0
 def render_GET(self, request):
     cal = HTMLCalendar()
     return cal.formatyear(self.year, 2)
コード例 #15
0
ファイル: ecalendar.py プロジェクト: yoza/base-elements
 def __init__(self, firstweekday=settings.FIRST_DAY_OF_WEEK):
     HTMLCalendar.__init__(self, firstweekday)
コード例 #16
0
ファイル: zcalendar.py プロジェクト: rpisarev/abi
 def __init__(self):
     """Retrieve and convert the localized first week day
     at initialization"""
     HTMLCalendar.__init__(self, AMERICAN_TO_EUROPEAN_WEEK_DAYS[
         get_format('FIRST_DAY_OF_WEEK')])
コード例 #17
0
ファイル: views.py プロジェクト: alanleegithub/webfaction
def about(request):
    c = HTMLCalendar(6).formatmonth(date.today().year, date.today().month)
    c = c.replace('>%s</td>' % date.today().day,
                  '><u><a href=#>%s</a></u></td>' % date.today().day)
    return render_to_response('about.html', {'calendar': c})
コード例 #18
0
ファイル: calendar.py プロジェクト: heyoni/DjangoProject
 def __init__(self, firstweekday):
     HTMLCalendar.__init__(self, firstweekday)
コード例 #19
0
def CalendarView(request):

    cal = HTMLCalendar().formatmonth(2020,10,withyear=True).replace('<td ', '<td  width="150" height="150"')

    return render(request, 'calendar.html', {'cal': cal})
コード例 #20
0
 def render_GET(self,request):
     cal = HTMLCalendar()
     return cal.formatyear(self.year,2)
コード例 #21
0
print(calendar.monthrange(2021,10))
print(calendar.monthcalendar(2019, 10))
print(calendar.prmonth(2021, 10))
print(calendar.prcal(2021))
print(calendar.day_name[0])
print(calendar.day_abbr[0])
print(calendar.month_name[1])
print(calendar.month_abbr[1])

print('--------------------------------')

c = Calendar()
print(list(c.itermonthdates(2021, 7)))
print(list(c.itermonthdays2(2020, 7)))
print(list(c.itermonthdays3(2021, 7)))
print(list(c.itermonthdays4(2021, 7)))

print('--------------------------------')

tx = TextCalendar()
print(tx.formatmonth(2021, 9))
print(tx.prmonth(2021, 9))
print(tx.formatyear(2021))
print(tx.pryear(2021))

print('---------------------------------')

hc = HTMLCalendar()
print(hc.formatmonth(2021, 10))
print(hc.formatyear(2021))
print(hc.formatyearpage(2021))