Exemplo n.º 1
0
def get_weekday_properties():
    dayabbrs = WEEKDAYS_ABBR.values() * 2
    daynames = WEEKDAYS.values() * 2
    weekday_names = []
    weekday_abbrs = []
    first_dow = standardise_first_dow(formats.get_format('FIRST_DAY_OF_WEEK'))

    for i in range(first_dow, first_dow + 7):
        weekday_names.append(daynames[i])
        weekday_abbrs.append(dayabbrs[i])
    return weekday_names, weekday_abbrs
Exemplo n.º 2
0
def first_day_of_week(dt):
    first_dow = standardise_first_dow(formats.get_format('FIRST_DAY_OF_WEEK'))
    return (datetime(dt.year, dt.month, dt.day) +
            relativedelta(weekday=first_dow, days=-6))
Exemplo n.º 3
0
)

from django.utils import formats
from django.utils.translation import ugettext_lazy as _
from django.utils.dates import MONTHS, MONTHS_3, WEEKDAYS, WEEKDAYS_ABBR

from calendartools.periods.proxybase import LocalizedSimpleProxy
from calendartools import defaults
from calendartools.utils import standardise_first_dow

__all__ = ['Period', 'Hour', 'Day', 'Week', 'Month', 'TripleMonth', 'Year',
           'first_day_of_week']

# Sensible default:
calendar.setfirstweekday(standardise_first_dow(
    formats.get_format('FIRST_DAY_OF_WEEK')
))

def get_weekday_properties():
    dayabbrs = WEEKDAYS_ABBR.values() * 2
    daynames = WEEKDAYS.values() * 2
    weekday_names = []
    weekday_abbrs = []
    first_dow = standardise_first_dow(formats.get_format('FIRST_DAY_OF_WEEK'))

    for i in range(first_dow, first_dow + 7):
        weekday_names.append(daynames[i])
        weekday_abbrs.append(dayabbrs[i])
    return weekday_names, weekday_abbrs

def first_day_of_week(dt):
 def week_format(self):
     first_dow = standardise_first_dow(formats.get_format('FIRST_DAY_OF_WEEK'))
     return '%W' if first_dow == calendar.MONDAY else '%U'